[rhq] Branch 'feature/cassandra-backend' - modules/enterprise modules/plugins
by Jiri Kremser
modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java | 82 +++++++---
modules/plugins/pom.xml | 1
2 files changed, 64 insertions(+), 19 deletions(-)
New commits:
commit 6ae4e86705e3821e1a3af1a53249d7cc60797baa
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Tue May 21 15:09:47 2013 +0200
Making the StorageNodeManagerBeanTest#testInit test passing; building the rhq-storage plugin by default
diff --git a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
index ff1b3b5..a486329 100644
--- a/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
+++ b/modules/enterprise/server/itests-2/src/test/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBeanTest.java
@@ -25,12 +25,15 @@
package org.rhq.enterprise.server.cloud;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.persistence.Query;
+import javax.transaction.Transaction;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -46,6 +49,7 @@ import org.rhq.core.domain.resource.ResourceCategory;
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.server.resource.ResourceTypeManagerLocal;
import org.rhq.enterprise.server.test.AbstractEJB3Test;
import org.rhq.enterprise.server.test.TransactionCallback;
import org.rhq.enterprise.server.util.LookupUtil;
@@ -57,11 +61,14 @@ import org.rhq.enterprise.server.util.LookupUtil;
public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
private StorageNodeManagerLocal nodeManager;
+ private ResourceTypeManagerLocal typeManager;
private Subject overlord;
+ private static final String TEST_PREFIX = "test-";
@Override
protected void beforeMethod() throws Exception {
nodeManager = LookupUtil.getStorageNodeManager();
+ typeManager = LookupUtil.getResourceTypeManager();
overlord = LookupUtil.getSubjectManager().getOverlord();
}
@@ -75,36 +82,55 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
@Override
public void execute() throws Exception {
- System.setProperty(cassandraSeedsProperty,
- "testhost|123|123,hostWithNoFoundResource|987|987,secondHostWithNoFoundResource|123|123");
-
- String testHostName = "testhost";
+ String testHostName = TEST_PREFIX + "hostname";
+ List<String> addresses = Arrays.asList(testHostName, TEST_PREFIX + "hostWithNoFoundResource",
+ TEST_PREFIX + "secondHostWithNoFoundResource");
+ System.setProperty(cassandraSeedsProperty, addresses.get(0) + "|123|123," + addresses.get(1)
+ + "|987|987," + addresses.get(2) + "|123|123");
cleanDatabase();
- ResourceType testResourceType = createResourceType();
+ // create the resource type if it doesn't exist
+ ResourceType testResourceType = typeManager.getResourceTypeByNameAndPlugin("RHQ Storage Node",
+ "RHQStorage");
+ if (testResourceType == null) {
+ testResourceType = createResourceType();
+ }
Resource testResource = createResource(testResourceType, testHostName);
+ // finds the storage nodes and pairs them w/ the associated resources
nodeManager.scanForStorageNodes();
+ // get the storage nodes and checks some properties on them
List<StorageNode> storageNodes = nodeManager.getStorageNodes();
- Assert.assertEquals(storageNodes.size(), 3);
+ Assert.assertNotNull(storageNodes, "The list of storage nodes shouldn't be null.");
+ Assert.assertFalse(storageNodes.isEmpty(), "The list of storage nodes shouldn't be empty.");
+ Assert.assertTrue(storageNodes.size() >= addresses.size(),
+ "The size of the list of storage nodes should be at least " + addresses.size());
+ List<String> obtainedAddresses = new ArrayList<String>(storageNodes.size());
for (StorageNode storageNode : storageNodes) {
- Assert.assertNotNull(storageNode.getAddress());
+ Assert.assertNotNull(storageNode.getAddress(), "Address of storage node cannot be null.");
+ obtainedAddresses.add(storageNode.getAddress());
if (storageNode.getAddress().equals(testHostName)) {
- Assert.assertNotNull(storageNode.getResource());
Assert.assertEquals(storageNode.getResource().getId(), testResource.getId());
+ Assert.assertNotNull(storageNode.getResource(), "Associated resource cannot be null.");
} else {
- Assert.assertNull(storageNode.getResource());
+ Assert.assertNull(storageNode.getResource(),
+ "The resource field should be null at this point.");
}
-
}
- cleanDatabase();
+ Assert.assertTrue(obtainedAddresses.containsAll(addresses),
+ "There are some storage nodes that should be created but were not discovered and returned."
+ + " The storage nodes that should be returned: " + addresses
+ + " The storage nodes that were returned: " + obtainedAddresses
+ + " (the second should be a super-set (not necessarily strict) of the first.)");
+
}
});
} finally {
+ cleanDatabase();
System.setProperty(cassandraSeedsProperty, originalSeedValue);
}
}
@@ -145,7 +171,8 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
StorageNodeCriteria criteria = new StorageNodeCriteria();
criteria.addFilterAddress(prefix);
- criteria.addSortAddress(PageOrdering.DESC); // use DESC just to make sure sorting on name is different than insert order
+ // use DESC just to make sure sorting on name is different than insert order
+ criteria.addSortAddress(PageOrdering.DESC);
PageList<StorageNode> list = nodeManager.findStorageNodesByCriteria(overlord, criteria);
assertTrue("The number of found storage nodes should be " + storageNodeCount + ". Was: " + list.size(),
@@ -159,7 +186,8 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
String prevAddress = null;
for (StorageNode s : list) {
- assert null == prevAddress || s.getAddress().compareTo(prevAddress) < 0 : "Results should be sorted by address DESC, something is out of order";
+ assert null == prevAddress || s.getAddress().compareTo(prevAddress) < 0 : "Results should be"
+ + "sorted by address DESC, something is out of order";
prevAddress = s.getAddress();
nodeAddresses.remove(s.getAddress());
}
@@ -172,22 +200,37 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
}
private void cleanDatabase() throws Exception {
- Query query = getEntityManager().createQuery("DELETE from StorageNode");
+ // this method is still needed, because tests calls SLSB methods that are executed in their own transaction
+ // and the rollback performed once the TransactionCallback is finished just wont clean everything
+
+ // pause the currently running TX
+ Transaction runningTransaction = getTransactionManager().suspend();
+ getTransactionManager().begin();
+
+ Query query = getEntityManager().createQuery("DELETE FROM StorageNode s WHERE s.address LIKE (:prefix || '%')")
+ .setParameter("prefix", TEST_PREFIX);
+
query.executeUpdate();
- query = getEntityManager().createQuery("DELETE from Availability");
+ // perhaps this could be restricted by resouce ids as well not to delete all the table with existing data
+ query = getEntityManager().createQuery("DELETE FROM Availability");
query.executeUpdate();
- query = getEntityManager().createQuery("DELETE from Resource");
+ query = getEntityManager().createQuery("DELETE FROM Resource r WHERE r.resourceKey LIKE (:prefix || '%')")
+ .setParameter("prefix", TEST_PREFIX);
query.executeUpdate();
- query = getEntityManager().createQuery("DELETE from ResourceType r WHERE r.name = :name").setParameter(
+ query = getEntityManager().createQuery("DELETE FROM ResourceType rt WHERE rt.name = :name").setParameter(
"name", "Cassandra Daemon");
query.executeUpdate();
+ getTransactionManager().commit();
+
+ // resume the currently running TX
+ getTransactionManager().resume(runningTransaction);
}
private ResourceType createResourceType() throws Exception {
- ResourceType resourceType = new ResourceType("Cassandra Daemon", "Cassandra", ResourceCategory.SERVER, null);
+ ResourceType resourceType = new ResourceType("RHQ Storage Node", "RHQStorage", ResourceCategory.SERVER, null);
ConfigurationDefinition pluginConfigurationDefinition = new ConfigurationDefinition("config", null);
pluginConfigurationDefinition.put(new PropertyDefinitionSimple("host", null, true, PropertySimpleType.STRING));
resourceType.setPluginConfigurationDefinition(pluginConfigurationDefinition);
@@ -197,10 +240,11 @@ public class StorageNodeManagerBeanTest extends AbstractEJB3Test {
}
private Resource createResource(ResourceType resourceType, String host) throws Exception {
- Resource resource = new Resource("CassandraDaemon", "CassandraDaemon (testhost)", resourceType);
+ Resource resource = new Resource(TEST_PREFIX + "CassandraDaemon", TEST_PREFIX + "CassandraDaemon", resourceType);
resource.setUuid(UUID.randomUUID().toString());
resource.getPluginConfiguration().setSimpleValue("host", host);
getEntityManager().persist(resource);
+ getEntityManager().flush();
return resource;
}
diff --git a/modules/plugins/pom.xml b/modules/plugins/pom.xml
index 7c08500..7f964f0 100644
--- a/modules/plugins/pom.xml
+++ b/modules/plugins/pom.xml
@@ -143,6 +143,7 @@
<module>script</module>
<module>iis</module>
<module>cassandra</module>
+ <module>rhq-storage</module>
</modules>
</profile>
11 years
[rhq] Branch 'feature/cassandra-backend' - 23 commits - .classpath etc/samples modules/common modules/core modules/enterprise modules/integration-tests modules/plugins
by John Sanda
.classpath | 2
etc/samples/embedded-ext-plugin/pom.xml | 72 +++
etc/samples/embedded-ext-plugin/src/main/java/org/rhq/sample/embeddedextplugin/EmbeddedExtensionDiscoveryComponent.java | 58 ++
etc/samples/embedded-ext-plugin/src/main/resources/META-INF/rhq-plugin.xml | 21 +
etc/samples/skeleton-plugin/pom.xml | 99 ----
etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildDiscoveryComponent.java | 47 ++
etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildServiceComponent.java | 61 ++
etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml | 20
etc/samples/skinny-platform/pom.xml | 60 ++
etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformComponent.java | 39 +
etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformDiscoveryComponent.java | 67 +++
etc/samples/skinny-platform/src/main/resources/META-INF/rhq-plugin.xml | 18
modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SecurityDomainJBossASClient.java | 31 +
modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java | 113 +++++
modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java | 27 +
modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java | 6
modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java | 5
modules/core/domain/src/main/resources/META-INF/persistence.xml | 8
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java | 2
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationUpgrade.java | 63 ++-
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 2
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 6
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java | 5
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 9
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 40 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java | 72 ++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java | 24 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 18
modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java | 9
modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java | 7
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 3
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 1
modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png |binary
modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/jboss-web.xml | 2
modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/web.xml | 4
modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/jboss-web.xml | 2
modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/web.xml | 4
modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js | 2
modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml | 1
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java | 8
modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java | 79 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 27 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java | 23 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java | 52 +-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentServiceMBean.java | 8
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java | 17
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/DelegatingLoginModule.java | 209 ++++++++++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java | 12
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java | 4
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 24 -
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryRunner.java | 17
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java | 2
modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/safeinvoker/HibernateDetachUtility.java | 4
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java | 11
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java | 50 +-
modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java | 2
modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml | 8
modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java | 2
74 files changed, 1339 insertions(+), 273 deletions(-)
New commits:
commit a1d636c68c858c6a7c37968587d3e004cbb5b81f
Merge: 828a99e 3ef61c1
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon May 20 22:05:57 2013 -0400
Merge branch 'master' into feature/cassandra-backend
commit 3ef61c1860a590b16b461b81f85b0011b2ee620d
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon May 20 13:36:45 2013 +0200
[BZ 958169] - Modified alert definition is not saved on confirming the save message after clicking on 'Back to List' button - New method for creating an alert definitions was added to SLSB, because the UI requires the ids of newly created alert conditions.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
index b90b209..8fe6d4b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
@@ -140,7 +140,7 @@ public class ConditionEditor extends EnhancedVLayout {
private AlertCondition existingCondition;
public ConditionEditor(HashSet<AlertCondition> conditions, Map<Integer, AlertCondition> modifiedConditions,
- SelectItem conditionExpression, ResourceType rtype, Runnable closeFunc, AlertCondition existingCondition) {
+ SelectItem conditionExpression, ResourceType rtype, AlertCondition existingCondition, Runnable closeFunc) {
super();
this.editMode = existingCondition != null;
this.existingCondition = existingCondition;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 782e4b5..8f4a36f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -196,7 +196,7 @@ public class ConditionsEditor extends EnhancedVLayout {
}
});
- table.addTableAction(MSG.common_button_edit(), null, new AbstractTableAction(TableActionEnablement.SINGLE) {
+ table.addTableAction(MSG.view_alert_definition_editCondition(), null, new AbstractTableAction(TableActionEnablement.SINGLE) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
AlertCondition condition = getDataSource().copyValues(selection[0]);
showConditionEditor(condition);
@@ -252,7 +252,7 @@ public class ConditionsEditor extends EnhancedVLayout {
final int numConditions = conditions.size();
final ConditionEditor newConditionEditor = new ConditionEditor(conditions, modifiedConditions,
ConditionsEditor.this.conditionExpression, ConditionsEditor.this.resourceType,
- new Runnable() {
+ existingCondition, new Runnable() {
@Override
public void run() {
updated = updated || numConditions != conditions.size()
@@ -260,7 +260,7 @@ public class ConditionsEditor extends EnhancedVLayout {
winModal.markForDestroy();
refresh();
}
- }, existingCondition);
+ });
winModal.addItem(newConditionEditor);
winModal.show();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 2cbe8c6..d69f7f4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -197,15 +197,14 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals,
final AsyncCallback<AlertDefinition> resultReceiver) {
if (alertDefinition.getId() == 0) {
- GWTServiceLookup.getAlertDefinitionService().createAlertDefinition(alertDefinition,
- Integer.valueOf(resource.getId()), new AsyncCallback<Integer>() {
+ GWTServiceLookup.getAlertDefinitionService().createAlertDefinitionAndReturn(alertDefinition,
+ Integer.valueOf(resource.getId()), new AsyncCallback<AlertDefinition>() {
@Override
- public void onSuccess(Integer result) {
+ public void onSuccess(AlertDefinition result) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_alert_definitions_create_success(), Severity.Info));
- alertDefinition.setId(result.intValue());
ResourceAlertDefinitionsView.this.refresh();
- resultReceiver.onSuccess(alertDefinition);
+ resultReceiver.onSuccess(result);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index c86d0cd..25742f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -146,10 +146,7 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
- // enable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
+ unregisterHandler();
setAlertDefinition(getAlertDefinition()); // reverts data back to original
makeViewOnly();
}
@@ -159,6 +156,15 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
addMember(tabSet);
addMember(buttons);
}
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ if (alertDefinition == null || alertDefinition.getId() == 0) {
+ // disable the back button when creating new definition
+ setBackButtonDisabled(true);
+ }
+ }
public AlertDefinition getAlertDefinition() {
return alertDefinition;
@@ -197,8 +203,7 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
recovery.makeEditable();
dampening.makeEditable();
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
+ unregisterHandler();
handlerRegistration = addVisibilityChangedHandler(new VisibilityChangedHandler() {
public void onVisibilityChanged(VisibilityChangedEvent event) {
if (!event.getIsVisible()) {
@@ -207,15 +212,13 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
if (value) {
save();
}
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
}
});
}
}
});
// disable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(true);
+ setBackButtonDisabled(true);
}
public void makeViewOnly() {
@@ -228,6 +231,7 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
notifications.makeViewOnly();
recovery.makeViewOnly();
dampening.makeViewOnly();
+ setBackButtonDisabled(false);
}
public void saveAlertDefinition() {
@@ -249,20 +253,13 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(final AlertDefinition alertDef) {
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
setAlertDefinition(alertDef);
- // enable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
+ unregisterHandler();
}
@Override
public void onFailure(Throwable caught) {
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
- // enable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
-
+ unregisterHandler();
// no error handling, the notification is done in the subclasses of AbstractAlertDefinitionsView
}
});
@@ -270,4 +267,22 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
tabSet.selectTab(generalPropertiesTab);
}
}
+
+ private void setBackButtonDisabled(boolean enabled) {
+ Canvas layoutCandidate = getParentElement();
+ if (layoutCandidate instanceof EnhancedVLayout) {
+ EnhancedVLayout parentLayout = (EnhancedVLayout) getParentElement();
+ Canvas backButton = parentLayout.getMember("backButton");
+ if (backButton != null) {
+ backButton.setDisabled(enabled);
+ }
+ }
+ }
+
+ private void unregisterHandler() {
+ if (handlerRegistration != null) {
+ handlerRegistration.removeHandler();
+ handlerRegistration = null;
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
index 0921b2b..794a67f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
@@ -32,6 +32,9 @@ public interface AlertDefinitionGWTService extends RemoteService {
int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException;
+ AlertDefinition createAlertDefinitionAndReturn(AlertDefinition alertDefinition, Integer resourceId)
+ throws RuntimeException;
+
AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, boolean purgeInternals)
throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index 181eef5..da1d981 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -66,8 +66,18 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
@Override
public int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException {
try {
- int results = alertDefManager.createAlertDefinitionInNewTransaction(getSessionSubject(), alertDefinition, resourceId, true);
- return results;
+ int result = alertDefManager.createAlertDefinitionInNewTransaction(getSessionSubject(), alertDefinition, resourceId, true);
+ return result;
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
+ public AlertDefinition createAlertDefinitionAndReturn(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException {
+ try {
+ AlertDefinition result = alertDefManager.createAlertDefinitionAndRerurnIt(getSessionSubject(), alertDefinition, resourceId, true);
+ return SerialUtility.prepare(result, "createAlertDefinitionAndReturn");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -77,9 +87,9 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition,
boolean resetMatching) throws RuntimeException {
try {
- AlertDefinition results = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId,
+ AlertDefinition result = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId,
alertDefinition, resetMatching);
- return SerialUtility.prepare(results, "updateAlertDefinition");
+ return SerialUtility.prepare(result, "updateAlertDefinition");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index d00a969..8f8fec5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -201,19 +201,30 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public int createDependentAlertDefinition(Subject subject, AlertDefinition alertDefinition, int resourceId)
throws InvalidAlertDefinitionException {
-
- return createAlertDefinitionInternal(subject, alertDefinition, resourceId, false, false);
+ AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, false,
+ false);
+ return newAlertDefinition.getId();
}
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- public int createAlertDefinitionInNewTransaction(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean validateNotificationConfiguration)
- throws InvalidAlertDefinitionException {
-
- return createAlertDefinitionInternal(subject, alertDefinition, resourceId, true, validateNotificationConfiguration);
+ public int createAlertDefinitionInNewTransaction(Subject subject, AlertDefinition alertDefinition,
+ Integer resourceId, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
+ AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, true,
+ validateNotificationConfiguration);
+ return newAlertDefinition.getId();
+ }
+
+ @Override
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public AlertDefinition createAlertDefinitionAndRerurnIt(Subject subject, AlertDefinition alertDefinition,
+ Integer resourceId, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
+ AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, true,
+ validateNotificationConfiguration);
+ return newAlertDefinition;
}
- private int createAlertDefinitionInternal(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean checkPerms, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
+ private AlertDefinition createAlertDefinitionInternal(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean checkPerms, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
checkAlertDefinition(subject, null, alertDefinition, resourceId, validateNotificationConfiguration);
// if this is an resource alert definition, set up the link to a resource
@@ -279,7 +290,7 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
AlertDefinitionEvent.CREATED);
}
- return alertDefinition.getId();
+ return alertDefinition;
}
private void fixRecoveryId(AlertDefinition definition) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
index 5afa1f9..ee0e161 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
@@ -65,6 +65,29 @@ public interface AlertDefinitionManagerLocal {
*/
int createAlertDefinitionInNewTransaction(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean finalizeNotificationConfiguration)
throws InvalidAlertDefinitionException;
+
+ /**
+ * Creates a new alert definition. Note that the suject is checked to have necessary authz, which might not
+ * be what you want in all use cases. See {@link #createDependentAlertDefinition(Subject, AlertDefinition, int)}
+ * for further discussion of this. The only difference between
+ * {@link GroupAlertDefinitionManagerLocal#createAlertDefinitionInNewTransaction(Subject, AlertDefinition, Integer, boolean)}
+ * and this method is the return type.
+ *
+ * @param subject the user creating the alert definition
+ * @param alertDefinition the new alert definition to persist
+ * @param resourceId the resource id for which the def is being created
+ * @param finalizeNotificationConfiguration if true, the configuration of the def's notifications is validated.
+ * This is NOT what you want if, for example, you are merely creating a copy of an existing definition.
+ * Some notifications might require more input when creating the notification than is then persisted in their configs
+ * (prominent example being the CLI alert sender).
+ * This would then cause the validation to fail every time you created a copy of a definition and tried
+ * to persist it. Note that passing false AND having new, unpersisted notifications in the alert definition can
+ * lead to invalid configuration being stored for the notifications.
+ * @return the instance of newly created alert definition
+ * @throws InvalidAlertDefinitionException
+ */
+ AlertDefinition createAlertDefinitionAndRerurnIt(Subject subject, AlertDefinition alertDefinition,
+ Integer resourceId, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException;
/**
* This is exactly the same as {@link #createAlertDefinitionInNewTransaction(Subject, AlertDefinition, Integer, boolean)} but
commit b638cc12a5796b7ccb3789bf94768303b0ce0e3c
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon May 20 13:29:43 2013 +0200
[BZ 958169] - Modified alert definition is not saved on confirming the save message after clicking on 'Back to List' button - I18n (Instead of "Edit", now the button label says "Edit Condition").
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 00a68ef..b630706 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -977,6 +977,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Trait Value
view_alert_definition_condition_editor_option_operation = Operation Execution
view_alert_definition_condition_editor_option_resource_configuration = Resource Configuration Change
view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = View Group Definition
view_alert_definition_for_type = View Template
view_alert_definition_notification_cliScript_editor_anotherUser = Another User
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index a27fb3c..cab205f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -993,6 +993,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Změna hodno
view_alert_definition_condition_editor_option_operation = Spuštění operace
view_alert_definition_condition_editor_option_resource_configuration = Změna konfigurace zdroje
view_alert_definition_condition_editor_resource_configuration_tooltip = Podmínka je splněna, když se změní konfigurace zdroje.
+view_alert_definition_editCondition = Editovat podmínku
view_alert_definition_for_group = Zobrazit definici skupiny
view_alert_definition_for_type = Zobrazit šablonu
view_alert_definition_notification_cliScript_editor_anotherUser = Jiný uživatel
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 902951d..057785a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -883,6 +883,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Änderung de
view_alert_definition_condition_editor_option_operation = Ausführung der Operation
view_alert_definition_condition_editor_option_resource_configuration = Änderung der Konfiguration der Ressource
##view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = Gruppendefinition ansehen
view_alert_definition_for_type = Vorlage ansehen
view_alert_definition_notification_cliScript_editor_anotherUser = Anderer Benutzer
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 8f47413..a929966 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -969,6 +969,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = トレイト
view_alert_definition_condition_editor_option_operation = オペレーションの実行
view_alert_definition_condition_editor_option_resource_configuration = リソース構成の変化
view_alert_definition_condition_editor_resource_configuration_tooltip = この条件はリソース構成が変更されると引き起こされます
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = ビューグループ定義
view_alert_definition_for_type = ビューテンプレート
view_alert_definition_notification_cliScript_editor_anotherUser = 別のユーザー
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index 5d19d06..da0a8a5 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -846,6 +846,7 @@ view_alert_definition_condition_editor_option_metric_threshold = 측정 절대
view_alert_definition_condition_editor_option_metric_trait_change = 특성값의 변화
view_alert_definition_condition_editor_option_resource_configuration = 자원 구성의 변화
view_alert_definition_condition_editor_resource_configuration_tooltip = 이 조건은 자원 구성이 변경되면 발생합니다.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = 뷰 그룹 정의
view_alert_definition_notification_cliScript_editor_anotherUser = 다른 사용자
view_alert_definition_notification_cliScript_editor_existingScript = 기존의 스크립트
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 743c4b5..9f342d7 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -977,6 +977,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Mudan\u00E7a
view_alert_definition_condition_editor_option_operation = Execu\u00E7\u00E3o de Opera\u00E7\u00E3o
view_alert_definition_condition_editor_option_resource_configuration = Mudan\u00E7a na Configura\u00E7\u00E3o do Recurso
view_alert_definition_condition_editor_resource_configuration_tooltip = Essa condi\u00E7\u00E3o \u00E9 disparada quando a configura\u00E7\u00E3o do recurso for alterada.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = Visualizar Defini\u00E7\u00E3o de Grupo
view_alert_definition_for_type = Visualizar Template
view_alert_definition_notification_cliScript_editor_anotherUser = Another User
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index 772c4e4..c8ee796 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -943,6 +943,7 @@
#view_alert_definition_condition_editor_option_operation = Operation Execution
#view_alert_definition_condition_editor_option_resource_configuration = Resource Configuration Change
#view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+##view_alert_definition_editCondition = Edit Condition
#view_alert_definition_for_group = View Group Definition
#view_alert_definition_for_type = View Template
#view_alert_definition_notification_cliScript_editor_anotherUser = Another User
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 03dfa4e..147b9f8 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -963,6 +963,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Trait Value
view_alert_definition_condition_editor_option_operation = Operation Execution
view_alert_definition_condition_editor_option_resource_configuration = \u8d44\u6e90\u914d\u7f6e\u6539\u53d8
view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = \u67e5\u770b\u7ec4\u5b9a\u4e49
view_alert_definition_for_type = \u67e5\u770b\u6a21\u677f
view_alert_definition_notification_cliScript_editor_anotherUser = \u5176\u4ed6\u7528\u6237
commit edaffb818aec221eb0db5338fcf2e669b06e5a70
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri May 17 17:09:35 2013 -0400
BZ 963982 - make sure we persist the token when the registration was successful, even if the server endpoint was bad
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index 6e1a95a..a8d8bdf 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -1376,6 +1376,7 @@ public class AgentMain {
try {
AgentRegistrationResults results = remote_pojo.registerAgent(request);
failover_list = results.getFailoverList();
+ token = results.getAgentToken(); // make sure our finally block gets this - BZ 963982
// Try to do a simple connect to each server in the failover list
// If only some of the servers are unreachable, just keep going;
@@ -1407,7 +1408,6 @@ public class AgentMain {
m_registration = results;
got_registered = true;
retry = false;
- token = results.getAgentToken();
LOG.info(AgentI18NResourceKeys.AGENT_REGISTRATION_RESULTS, results);
} finally {
// stores the new one if successful; restores the old one if we failed for some reason to register
commit 92fd97dd84324980487972bda6f424114e1e712d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 17 14:11:32 2013 +0200
BZ 962858 check passed resource id and return 404 if invalid
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 288e9f7..70cc588 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
@@ -559,6 +559,10 @@ public class ResourceHandlerBean extends AbstractRestBean {
@ApiOperation("Get a list of links to the alerts for the passed resource")
public List<Link> getAlertsForResource(@ApiParam("Id of the resource to query") @PathParam("id") int resourceId) {
AlertCriteria criteria = new AlertCriteria();
+
+ // Check for resource existence
+ fetchResource(resourceId);
+
criteria.addFilterResourceIds(resourceId);
List<Alert> alerts = alertManager.findAlertsByCriteria(caller, criteria);
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 3efd807..cc9558b 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
@@ -593,6 +593,17 @@ public class ResourcesTest extends AbstractBase {
}
@Test
+ public void testAlertsForUnknownResource() throws Exception {
+ given()
+ .header("Accept", "application/json")
+ .pathParam("id", 12345)
+ .expect()
+ .statusCode(404)
+ .when()
+ .get("/resource/{id}/alerts");
+ }
+
+ @Test
public void testSchedulesForResource() throws Exception {
given()
.header("Accept", "application/json")
commit b8207e9ec0efcf679af774e870f1c3b70fafc6fc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 17 09:26:14 2013 +0200
Disable for the moment
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java
index 7e20630..3a7e961 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java
@@ -703,7 +703,7 @@ public class ConfigurationHelperTest {
}
- @Test
+ @Test(enabled = false)
public void testConfigToMapComplexMapWithBadSetupLenient() throws Exception {
Configuration config = new Configuration();
commit 9a040dd824209eb9e71bb22c7cf7d80a7c468485
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri May 17 12:41:31 2013 +0200
[BZ 958169] - Modified alert definition is not saved on confirming the save message after clicking on 'Back to List' button - Making the "Back to List" button disabled when editing the alert definition.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
index 14b6abf..d915cb0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
@@ -1,8 +1,5 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
-import java.util.Map;
-
-import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertDefinition;
/**
@@ -12,8 +9,6 @@ public interface EditAlertDefinitionForm {
AlertDefinition getAlertDefinition();
-// Map<Integer, AlertCondition> getUpdatedAlertConditions();
-
boolean isResetMatching();
void setAlertDefinition(AlertDefinition alertDef);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index b4504c9..c86d0cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -28,6 +28,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Button;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.VisibilityChangedEvent;
@@ -145,7 +146,10 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- handlerRegistration.removeHandler();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
+ // enable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
setAlertDefinition(getAlertDefinition()); // reverts data back to original
makeViewOnly();
}
@@ -193,6 +197,8 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
recovery.makeEditable();
dampening.makeEditable();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
handlerRegistration = addVisibilityChangedHandler(new VisibilityChangedHandler() {
public void onVisibilityChanged(VisibilityChangedEvent event) {
if (!event.getIsVisible()) {
@@ -201,12 +207,15 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
if (value) {
save();
}
- handlerRegistration.removeHandler();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
}
});
}
}
});
+ // disable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(true);
}
public void makeViewOnly() {
@@ -240,13 +249,21 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(final AlertDefinition alertDef) {
- handlerRegistration.removeHandler();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
setAlertDefinition(alertDef);
+ // enable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
}
@Override
public void onFailure(Throwable caught) {
- // nothing, the notification is done in the subclasses of AbstractAlertDefinitionsView
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
+ // enable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
+
+ // no error handling, the notification is done in the subclasses of AbstractAlertDefinitionsView
}
});
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java
index efab26d..41819e1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java
@@ -41,6 +41,7 @@ public class BackButton extends StretchImgButton {
public BackButton(String title, final String anchor) {
this();
setTitle("<b>" + title + "</b>");
+ setID("backButton");
addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
CoreGUI.goToView(anchor);
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png
new file mode 100644
index 0000000..c323816
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png
new file mode 100644
index 0000000..d6cf484
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png
new file mode 100644
index 0000000..2addd3a
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png differ
commit d074bd8fa3daf63342bd5426e8599b0cb8f10cef
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 16 21:47:39 2013 +0200
We don't need standalone-osgi.xml
diff --git a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
index 05619cb..e9f3bbe 100644
--- a/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
+++ b/modules/enterprise/server/appserver/src/main/scripts/rhq-container.build.xml
@@ -220,6 +220,7 @@
<fileset dir="${jboss.home}/standalone/configuration">
<include name="standalone-ha.xml" />
<include name="standalone.xml" />
+ <include name="standalone-osgi.xml" />
<include name="standalone-full-ha.xml" />
</fileset>
</delete>
commit 4e91d0dc17e549213f61ee6a9251423d65c4ccce
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 16 21:47:23 2013 +0200
Fix a small typo
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 5415ed0..902951d 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -1235,7 +1235,7 @@ view_core_uncaught = Es ist eine nicht abgefangene Ausnahme aufgetreten.
view_dashboardManager_deleteFail = Konnte das Dashboard nicht löschen.
view_dashboardManager_deleted = Dashboard {0} erfolgreich gelöscht
view_dashboardManager_error = Konnte das Dashboard nicht auf dem Server sichern
-view_dashboardManager_saved = Das Dashboard {0} wurde auf dem Server geichert
+view_dashboardManager_saved = Das Dashboard {0} wurde auf dem Server gesichert
view_dashboardManager_success = Dashboard gespeichert
view_dashboard_favorites_error1 = Konnte die Ressoucen-Lesezeichen nicht laden
view_dashboardsManager_error1 = Konnte das neue Dashboard nicht hinzufügen
commit ba97ade9666a32cd20e071110c98a45e32d7f9fc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu May 16 21:47:08 2013 +0200
BZ 961656 - enable LDAP support for the REST-api as well.
diff --git a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SecurityDomainJBossASClient.java b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SecurityDomainJBossASClient.java
index 5caa45e..99e2f4d 100644
--- a/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SecurityDomainJBossASClient.java
+++ b/modules/common/jboss-as-dmr-client/src/main/java/org/rhq/common/jbossas/client/controller/SecurityDomainJBossASClient.java
@@ -39,6 +39,7 @@ public class SecurityDomainJBossASClient extends JBossASClient {
public static final String SECURITY_DOMAIN = "security-domain";
public static final String CACHE_TYPE = "cache-type";
public static final String AUTHENTICATION = "authentication";
+ public static final String LOGIN_MODULE = "login-module";
public static final String LOGIN_MODULES = "login-modules";
public static final String CLASSIC = "classic";
public static final String CODE = "code";
@@ -376,6 +377,36 @@ public class SecurityDomainJBossASClient extends JBossASClient {
return;
}
+ /**
+ * send a :flush-cache operation to the passed security domain
+ * @param domain simple name of the domain
+ * @throws Exception
+ */
+ public void flushSecurityDomainCache(String domain) throws Exception {
+ Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN,domain);
+ ModelNode request = createRequest("flush-cache",addr);
+ ModelNode result = execute(request);
+ if (!isSuccess(result)) {
+ log.warn("Flushing " + domain + " failed - principals may be longer cached than expected");
+ }
+ }
+
+ /**
+ * Check if a certain login module is present inside the passed security domain
+ * @param domainName Name of the security domain
+ * @param moduleName Name of the Login module - wich usually is it FQCN
+ * @return True if the module is present
+ * @throws Exception
+ */
+ public boolean securityDomainHasLoginModule(String domainName, String moduleName) throws Exception {
+ Address addr = Address.root().add(SUBSYSTEM, SUBSYSTEM_SECURITY, SECURITY_DOMAIN,domainName);
+ addr.add(AUTHENTICATION,CLASSIC);
+ addr.add(LOGIN_MODULE,moduleName);
+ ModelNode request = createRequest("read-resource", addr);
+ ModelNode response = execute(request);
+ return isSuccess(response);
+ }
+
/** Immutable helper */
public static class LoginModuleRequest {
private AppConfigurationEntry entry;
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/jboss-web.xml b/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/jboss-web.xml
index 319b990..a98b367 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/jboss-web.xml
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/jboss-web.xml
@@ -2,4 +2,6 @@
<jboss-web>
<security-domain>RHQRESTSecurityDomain</security-domain>
+ <!-- see https://community.jboss.org/wiki/JBossAS7SecurityAuditing for the next tag -->
+ <!--<disable-audit>false</disable-audit>-->
</jboss-web>
diff --git a/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/web.xml
index fb75d94..b601346 100644
--- a/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/rest-examples-war/src/main/webapp/WEB-INF/web.xml
@@ -10,7 +10,7 @@
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
- <role-name>all</role-name>
+ <role-name>rest-user</role-name>
</auth-constraint>
</security-constraint>
@@ -21,7 +21,7 @@
<security-role>
<description>This is valid for all principals, as we do internal checks</description>
- <role-name>all</role-name>
+ <role-name>rest-user</role-name>
</security-role>
</web-app>
diff --git a/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/jboss-web.xml b/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/jboss-web.xml
index 1ef5880..28f365f 100644
--- a/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/jboss-web.xml
+++ b/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/jboss-web.xml
@@ -3,4 +3,6 @@
<jboss-web>
<context-root>rest</context-root>
<security-domain>RHQRESTSecurityDomain</security-domain>
+ <!-- see https://community.jboss.org/wiki/JBossAS7SecurityAuditing for the next tag -->
+ <!--<disable-audit>false</disable-audit>-->
</jboss-web>
diff --git a/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/web.xml b/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/web.xml
index f96839d..f336c60 100644
--- a/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/web.xml
+++ b/modules/enterprise/gui/rest-war/src/main/webapp/WEB-INF/web.xml
@@ -57,7 +57,7 @@
<url-pattern>/*</url-pattern>
</web-resource-collection>
<auth-constraint>
- <role-name>all</role-name>
+ <role-name>rest-user</role-name>
</auth-constraint>
</security-constraint>
@@ -68,7 +68,7 @@
<security-role>
<description>This is valid for all principals, as we do internal checks</description>
- <role-name>all</role-name>
+ <role-name>rest-user</role-name>
</security-role>
</web-app>
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
index 8173e68..0b9c078 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/InstallerServiceImpl.java
@@ -278,6 +278,9 @@ public class InstallerServiceImpl implements InstallerService {
// Set up the logging subsystem
ServerInstallUtil.configureLogging(mcc, serverProperties);
+ ServerInstallUtil.createUserSecurityDomain(mcc);
+ ServerInstallUtil.createRestSecurityDomain(mcc);
+
// create a keystore whose cert has a CN of this server's public endpoint address
File keystoreFile = ServerInstallUtil.createKeystore(serverDetails != null ? serverDetails
: getServerDetailsFromPropertiesOnly(serverProperties), appServerConfigDir);
@@ -601,7 +604,7 @@ public class InstallerServiceImpl implements InstallerService {
* Save the given properties to the server's .properties file.
*
* Note that this is private - it is not exposed to the installer UI. It should have no need to save
- * this data outside of the normal installation process (see {@link #install()}).
+ * this data outside of the normal installation process (see {@link #install}).
*
* @param serverProperties the server properties to save
* @throws Exception if failed to save the properties to the .properties file
@@ -1013,9 +1016,6 @@ public class InstallerServiceImpl implements InstallerService {
// create the security domain needed by the datasources
ServerInstallUtil.createDatasourceSecurityDomain(mcc, serverProperties);
- // create the security domain needed by REST
- ServerInstallUtil.createRESTSecurityDomain(mcc, serverProperties);
-
// set up REST cache
ServerInstallUtil.createNewCaches(mcc, serverProperties);
diff --git a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
index d6e0d10..3a19833 100644
--- a/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
+++ b/modules/enterprise/server/installer/src/main/java/org/rhq/enterprise/server/installer/ServerInstallUtil.java
@@ -38,6 +38,8 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
+import javax.security.auth.login.AppConfigurationEntry;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.tools.ant.Project;
@@ -133,8 +135,6 @@ public class ServerInstallUtil {
"jboss.management.https.port", 6443));
defaultSocketBindings.add(new SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_MGMT_NATIVE,
"jboss.management.native.port", 6999));
- defaultSocketBindings.add(new SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_OSGI_HTTP,
- "rhq.server.socket.binding.port.osgi-http", 7090, false));
defaultSocketBindings.add(new SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_REMOTING,
"rhq.server.socket.binding.port.remoting", 3447));
defaultSocketBindings.add(new SocketBindingInfo(SocketBindingJBossASClient.DEFAULT_BINDING_TXN_RECOVERY_ENV,
@@ -146,7 +146,10 @@ public class ServerInstallUtil {
private static final String RHQ_DATASOURCE_NAME_NOTX = "NoTxRHQDS";
private static final String RHQ_DATASOURCE_NAME_XA = "RHQDS";
private static final String RHQ_DS_SECURITY_DOMAIN = "RHQDSSecurityDomain";
+ private static final String RHQ_USER_SECURITY_DOMAIN = "RHQUserSecurityDomain";
private static final String RHQ_REST_SECURITY_DOMAIN = "RHQRESTSecurityDomain";
+ private static final String JDBC_LOGIN_MODULE_NAME = "org.rhq.enterprise.server.core.jaas.JDBCLoginModule";
+ private static final String DELEGATIG_LOGIN_MODULE_NAME = "org.rhq.enterprise.server.core.jaas.DelegatingLoginModule";
private static final String JDBC_DRIVER_POSTGRES = "postgres";
private static final String JDBC_DRIVER_ORACLE = "oracle";
private static final String JMS_ALERT_CONDITION_QUEUE = "AlertConditionQueue";
@@ -299,6 +302,48 @@ public class ServerInstallUtil {
}
/**
+ * Create the standard user security domain with the JDBCLogin module installed
+ *
+ * @param mcc ModelControllerClient to talk to the underlying AS
+ * @throws Exception If anything goes wrong
+ */
+ public static void createUserSecurityDomain(ModelControllerClient mcc) throws Exception {
+
+ Map<String,String> options = new HashMap<String, String>(2);
+ options.put("hashAlgorithm", "MD5");
+ options.put("hashEncoding", "base64");
+
+ SecurityDomainJBossASClient.LoginModuleRequest loginModuleRequest = new SecurityDomainJBossASClient.LoginModuleRequest(JDBC_LOGIN_MODULE_NAME,
+ AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, options);
+
+
+ SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
+ client.createNewSecurityDomain(RHQ_USER_SECURITY_DOMAIN,loginModuleRequest);
+
+ }
+
+ /**
+ * Create a security domain for container managed security used with the rhq-rest.war
+ * @param mcc ModelControllerClient to talk to the underlying AS.
+ * @throws Exception If anything goes wrong
+ */
+ public static void createRestSecurityDomain(ModelControllerClient mcc) throws Exception {
+
+ Map<String,String> options = new HashMap<String, String>(2);
+ options.put("delegateTo", RHQ_USER_SECURITY_DOMAIN);
+ options.put("roles", "rest-user");
+
+ SecurityDomainJBossASClient.LoginModuleRequest loginModuleRequest = new SecurityDomainJBossASClient.LoginModuleRequest(DELEGATIG_LOGIN_MODULE_NAME,
+ AppConfigurationEntry.LoginModuleControlFlag.SUFFICIENT, options);
+
+
+ SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
+ client.createNewSecurityDomain(RHQ_REST_SECURITY_DOMAIN,loginModuleRequest);
+ }
+
+
+
+ /**
* Creates the JMS Queues required for Drift and Alerting.
*
* @param mcc the JBossAS management client
@@ -367,28 +412,6 @@ public class ServerInstallUtil {
return;
}
- /**
- * Creates the security domain for REST.
- *
- * @param mcc the JBossAS management client
- * @param serverProperties contains the obfuscated password to store in the security domain
- * @throws Exception
- */
- public static void createRESTSecurityDomain(ModelControllerClient mcc, HashMap<String, String> serverProperties)
- throws Exception {
-
- final SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
- final String securityDomain = RHQ_REST_SECURITY_DOMAIN;
- if (!client.isSecurityDomain(securityDomain)) {
- String dsJndiName = "java:jboss/datasources/" + RHQ_DATASOURCE_NAME_XA;
- client.createNewDatabaseServerSecurityDomain72(securityDomain, dsJndiName,
- "SELECT PASSWORD FROM RHQ_PRINCIPAL WHERE principal=?",
- "SELECT 'all', 'Roles' FROM RHQ_PRINCIPAL WHERE principal=?", null, null);
- LOG.info("Security domain [" + securityDomain + "] created");
- } else {
- LOG.info("Security domain [" + securityDomain + "] already exists, skipping the creation request");
- }
- }
/**
* Creates the Infinispan caches for RHQ.
@@ -856,7 +879,7 @@ public class ServerInstallUtil {
/**
* Returns a database connection with the given set of properties providing the settings that allow for a successful
* database connection. If <code>props</code> is <code>null</code>, it will use the server properties from
- * {@link #getServerProperties()}.
+ * {@link #getServerProperties}.
*
* @param connectionUrl
* @param userName
@@ -898,7 +921,7 @@ public class ServerInstallUtil {
* Use the internal JBossAS mechanism to de-obfuscate a password back to its
* clear text form. This is not true encryption.
*
- * @param obfuscatedPasswordd the obfuscated password
+ * @param obfuscatedPassword the obfuscated password
* @return the clear-text password
*/
public static String deobfuscatePassword(String obfuscatedPassword) {
@@ -1003,7 +1026,7 @@ public class ServerInstallUtil {
/**
* This will create the database schema in the database. <code>props</code> define the connection to the database -
*
- * <p>Note that if the {@link #isDatabaseSchemaExist(Properties) schema already exists}, it will be purged of all
+ * <p>Note that if the {@link #isDatabaseSchemaExist schema already exists}, it will be purged of all
* data/tables and recreated.</p>
*
* @param props the full set of server properties
@@ -1039,7 +1062,7 @@ public class ServerInstallUtil {
/**
* This will update an existing database schema so it can be upgraded to the latest schema version.
*
- * <p>Note that if the {@link #isDatabaseSchemaExist(Properties) schema does not already exist}, errors will
+ * <p>Note that if the {@link #isDatabaseSchemaExist schema does not already exist}, errors will
* occur.</p>
*
* @param props the full set of server properties
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
index 95dd58f..73eeca5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentService.java
@@ -57,7 +57,6 @@ import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceMBean, MBeanRegistration {
private Log log = LogFactory.getLog(CustomJaasDeploymentService.class.getName());
- private MBeanServer mbeanServer = null;
/**
* Constructor for {@link CustomJaasDeploymentService}.
@@ -70,21 +69,51 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
*/
public void installJaasModules() {
try {
- log.info("Installing RHQ Server's JAAS login modules");
+ log.info("Updating RHQ Server's JAAS login modules");
Properties systemConfig = LookupUtil.getSystemManager().getSystemConfiguration(
LookupUtil.getSubjectManager().getOverlord());
- registerJaasModules(systemConfig);
+ updateJaasModules(systemConfig);
} catch (Exception e) {
log.fatal("Error deploying JAAS login modules", e);
throw new RuntimeException(e);
}
}
+ @Override
+ public void upgradeRhqUserSecurityDomainIfNeeded() {
+ try {
+ Properties systemConfig = LookupUtil.getSystemManager().getSystemConfiguration(
+ LookupUtil.getSubjectManager().getOverlord());
+
+ String value = systemConfig.getProperty(SystemSetting.LDAP_BASED_JAAS_PROVIDER.getInternalName());
+ boolean isLdapAuthenticationEnabled = (value != null) ? RHQConstants.LDAPJAASProvider.equals(value) : false;
+
+ if (isLdapAuthenticationEnabled) {
+
+ ModelControllerClient mcc = null;
+ mcc = ManagementService.getClient();
+ final SecurityDomainJBossASClient client = new SecurityDomainJBossASClient(mcc);
+
+ boolean ldapModulesPresent = client.securityDomainHasLoginModule(RHQ_USER_SECURITY_DOMAIN,
+ "org.rhq.enterprise.server.core.jaas.LdapLoginModule");
+
+
+ if (!ldapModulesPresent) {
+ log.info("Updating RHQ Server's JAAS login modules with LDAP support");
+ updateJaasModules(systemConfig);
+ }
+ }
+ } catch (Exception e) {
+ log.fatal("Error deploying JAAS login modules", e);
+ throw new RuntimeException(e);
+ }
+
+ }
+
/**
* @see javax.management.MBeanRegistration#preRegister(javax.management.MBeanServer,javax.management.ObjectName)
*/
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
- this.mbeanServer = server;
return name;
}
@@ -107,13 +136,13 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
}
/**
- * Will register the necessary JAAS login Modules. The RHQ_USER_SECURITY_DOMAIN will be created, or recreated
- * if it already exists. This allows us to add/remove ldap support as it is enabled or disabled.
- *
- * @param systemConfig
+ * Will update the necessary JAAS login Modules. The RHQ_USER_SECURITY_DOMAIN will be created, or recreated
+ * if it already exists. This allows us to add/remove ldap support as it is enabled or disabled.
+ *
+ * @param systemConfig System configuration to read the LDAP settings from
* @throws Exception
*/
- private void registerJaasModules(Properties systemConfig) throws Exception {
+ private void updateJaasModules(Properties systemConfig) throws Exception {
ModelControllerClient mcc = null;
try {
@@ -144,7 +173,7 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
AppConfigurationEntry.LoginModuleControlFlag.REQUISITE, getJdbcOptions(systemConfig));
loginModules.add(jdbcPrincipalCheckLoginModule);
- // this is the LDAP module that checks the LDAP for auth
+ // this is the LDAP module that checks the LDAP for auth
Map<String, String> ldapModuleOptionProperties = getLdapOptions(systemConfig);
try {
validateLdapOptions(ldapModuleOptionProperties);
@@ -170,7 +199,8 @@ public class CustomJaasDeploymentService implements CustomJaasDeploymentServiceM
client.createNewSecurityDomain(RHQ_USER_SECURITY_DOMAIN,
loginModules.toArray(new LoginModuleRequest[loginModules.size()]));
- log.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] created with login modules " + loginModules);
+ client.flushSecurityDomainCache("RHQRESTSecurityDomain");
+ log.info("Security domain [" + RHQ_USER_SECURITY_DOMAIN + "] re-created with login modules " + loginModules);
} catch (Exception e) {
throw new Exception("Error registering RHQ JAAS modules", e);
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentServiceMBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentServiceMBean.java
index 8d53e2b..47fcc48 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentServiceMBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/CustomJaasDeploymentServiceMBean.java
@@ -41,4 +41,12 @@ public interface CustomJaasDeploymentServiceMBean {
* Installs the JAAS Modules that JON Server uses to allow users to log in.
*/
void installJaasModules();
+
+ /**
+ * Called from the startup bean and will upgrade an existing
+ * RHQUserSecurityDomain if needed - that is if the system
+ * settings say that LDAP support is enabled, but the underlying
+ * modules are not present
+ */
+ void upgradeRhqUserSecurityDomainIfNeeded();
}
\ No newline at end of file
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
index 90ffbaf..7963b26 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/StartupBean.java
@@ -95,7 +95,7 @@ import org.rhq.enterprise.server.util.concurrent.AvailabilityReportSerializer;
* This startup singleton EJB performs the rest of the RHQ Server startup initialization.
* In order for it to do its work properly, we must ensure everything has been deployed and started;
* specifically, all EJBs must have been deployed and available.
- *
+ *
* This bean is not meant for client consumption - it is only for startup initialization.
*/
@Singleton
@@ -195,7 +195,7 @@ public class StartupBean implements StartupLocal {
initScheduler(); // make sure this is initialized before starting the plugin deployer
startPluginDeployer(); // make sure this is initialized before starting the server plugin container
startServerPluginContainer(); // before comm in case an agent wants to talk to it
- installJaasModules();
+ upgradeRhqUserSecurityDomainIfNeeded();
startServerCommunicationServices();
startScheduler();
scheduleJobs();
@@ -396,8 +396,7 @@ public class StartupBean implements StartupLocal {
*
* @throws RuntimeException
*/
- private void installJaasModules() throws RuntimeException {
- log.info("Installing JAAS login modules...");
+ private void upgradeRhqUserSecurityDomainIfNeeded() throws RuntimeException {
try {
CustomJaasDeploymentServiceMBean jaas_mbean;
@@ -406,9 +405,9 @@ public class StartupBean implements StartupLocal {
Class<?> iface = CustomJaasDeploymentServiceMBean.class;
jaas_mbean = (CustomJaasDeploymentServiceMBean) MBeanServerInvocationHandler.newProxyInstance(mbs, name,
iface, false);
- jaas_mbean.installJaasModules();
+ jaas_mbean.upgradeRhqUserSecurityDomainIfNeeded();
} catch (Exception e) {
- throw new RuntimeException("Cannot install JAAS login modules!", e);
+ throw new RuntimeException("Cannot upgrade JAAS login modules!", e);
}
}
@@ -632,7 +631,7 @@ public class StartupBean implements StartupLocal {
log.error("Cannot schedule server plugin jobs.", e);
}
- // Alerting Availability Duration Job (create only, nothing actually scheduled here)
+ // Alerting Availability Duration Job (create only, nothing actually scheduled here)
try {
schedulerBean.scheduleTriggeredJob(AlertAvailabilityDurationJob.class, false, null);
} catch (Exception e) {
@@ -647,7 +646,7 @@ public class StartupBean implements StartupLocal {
* immediately begin to send any persisted guaranteed messages that might already exist. This method must be called
* at a time when the server is ready to accept messages from agents because any guaranteed messages that are
* delivered might trigger the agents to send messages back to the server.
- *
+ *
* NOTE: we don't need to do this - so far, none of the messages the server sends to the agent are marked
* with "guaranteed delivery" (this is on purpose and a good thing) so we don't need to start all the agent clients
* in case they have persisted messages. Since the number of agents could be large this cache could be huge and
@@ -673,7 +672,7 @@ public class StartupBean implements StartupLocal {
* Starts the embedded agent, but only if the embedded agent is installed and it is enabled.
*
* @throws RuntimeException if the agent is installed and enabled but failed to start
- *
+ *
* @deprecated we don't have an embedded agent anymore, leaving this in case we resurrect it
*/
private void startEmbeddedAgent() throws RuntimeException {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/DelegatingLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/DelegatingLoginModule.java
new file mode 100644
index 0000000..d89c04b
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/DelegatingLoginModule.java
@@ -0,0 +1,209 @@
+/*
+ * 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.enterprise.server.core.jaas;
+
+import java.io.IOException;
+import java.security.Principal;
+import java.security.acl.Group;
+import java.util.List;
+import java.util.Map;
+
+import javax.security.auth.Subject;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.jboss.security.SimpleGroup;
+import org.jboss.security.SimplePrincipal;
+import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
+
+import org.rhq.core.util.StringUtil;
+
+/**
+ * A login module that just delegates all work to a different security domain.<p/>
+ * When you use container managed security (CMS), EAP 6.1 requires the security domain being
+ * already present in standalone.xml
+ *
+ * With our setup we (re)-create the security domain of RHQUserSecurityDomain dynamically,
+ * which makes CMS fail on startup and also on re-create.
+ *
+ * The approach of just exchanging login modules does not work correctly either (principals
+ * keep being cached, server goes into need-reload state).
+ *
+ * So we now have a security domain for the CMS for the REST api that just delegates to the
+ * RHQUserSecuritDomain.
+ *
+ * <pre>
+ * <security-domain name="RHQRESTSecurityDomain" cache-type="default">
+ * <authentication>
+ * <login-module code="org.rhq.enterprise.server.core.jaas.DelegatingLoginModule" flag="required">
+ * <module-option name="delegateTo" value="RHQUserSecurityDomain"/>
+ * <module-option name="additionalRoles" value="rest-user"/>
+ * </login-module>
+ * </authentication>
+ * </security-domain>
+ *</pre>
+ *
+ * @author Heiko W. Rupp
+ */
+@SuppressWarnings("unused")
+public class DelegatingLoginModule extends UsernamePasswordLoginModule {
+
+ private static Log LOG = LogFactory.getLog("DelegatingLoginModule");
+
+ LoginContext loginContext;
+ private String[] usernamePassword;
+ private Principal identity;
+ private List<String> rolesList;
+ private boolean debugEnabled;
+
+ @Override
+ public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String, ?> sharedState,
+ Map<String, ?> options) {
+
+ debugEnabled = log.isDebugEnabled();
+
+ super.initialize(subject, callbackHandler, sharedState, options);
+
+ /* This is the login context (=security domain) we want to delegate to */
+ String delegateTo = (String) options.get("delegateTo");
+
+ /* Comma separated list of roles that should be set for the principal */
+ String additionalRoles = (String) options.get("roles");
+ rolesList = StringUtil.explode(additionalRoles, ",");
+
+ if (delegateTo ==null || delegateTo.isEmpty()) {
+ delegateTo = "other";
+ LOG.warn("module-option 'delegateTo' was not set. Defaults to 'other'.");
+ }
+
+ if (debugEnabled) {
+ log.debug("Delegating to " + delegateTo + " with roles " + additionalRoles);
+ }
+
+ // Now create the context for later use
+ try {
+ loginContext = new LoginContext(delegateTo, new DelegateCallbackHandler());
+ } catch (LoginException e) {
+ log.warn("Initialize failed : " + e.getMessage());
+ }
+ }
+
+ /**
+ * Do the actual login work - we obtain the user/password passed in and then try to
+ * log into the delegated context. If this succeeds, we tell the super-module,
+ * so this can do further processing (especially running the #commit() method).
+ *
+ * @return True on success
+ * @throws LoginException If anything goes wrong
+ */
+ @Override
+ public boolean login() throws LoginException {
+ try {
+ // Get the username / password the user entred and save if for later use
+ usernamePassword = super.getUsernameAndPassword();
+
+ // Try to log in via the delegate
+ loginContext.login();
+
+ // Nix out the password
+ usernamePassword[1] = null;
+
+ // login was success, so we can continue
+ identity = createIdentity(usernamePassword[0]);
+ useFirstPass=true;
+
+ // This next flag is important. Without it the principal will not be
+ // propagated
+ loginOk = true;
+
+ if (debugEnabled) {
+ log.debug("Login ok for " + usernamePassword[0]);
+ }
+
+ return true;
+ } catch (Exception e) {
+ if (debugEnabled) {
+ LOG.debug("Login failed for : " + usernamePassword[0] + ": " + e.getMessage());
+ }
+ loginOk = false;
+ return false;
+ }
+ }
+
+
+ @Override
+ protected String getUsersPassword() throws LoginException {
+
+ // This is not used but abstract in super.
+ return null;
+ }
+
+ @Override
+ protected Principal getIdentity() {
+ return identity;
+ }
+
+
+ @Override
+ protected Group[] getRoleSets() throws LoginException {
+
+ SimpleGroup roles = new SimpleGroup("Roles");
+
+ for (String role : rolesList ) {
+ roles.addMember( new SimplePrincipal(role));
+ }
+ Group[] roleSets = { roles };
+ return roleSets;
+ }
+
+
+ /**
+ * Handle the callbacks from the other security domain that we delegate to
+ */
+ private class DelegateCallbackHandler implements CallbackHandler {
+ @Override
+ public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
+
+ if (debugEnabled) {
+ LOG.debug("private handle callbacks");
+ }
+ for (Callback cb : callbacks) {
+ if (cb instanceof NameCallback) {
+ NameCallback nc = (NameCallback) cb;
+ nc.setName(usernamePassword[0]);
+ }
+ else if (cb instanceof PasswordCallback) {
+ PasswordCallback pc = (PasswordCallback) cb;
+ pc.setPassword(usernamePassword[1].toCharArray());
+ }
+ else {
+ throw new UnsupportedCallbackException(cb,"Callback " + cb + " not supported");
+ }
+ }
+ }
+ }
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java
index 10fef1a..d12336e 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCLoginModule.java
@@ -50,7 +50,7 @@ import org.rhq.enterprise.server.RHQConstants;
* this value is "SELECT password FROM principals WHERE principal=?"
*
* dsJndiName
- * JNDI name of the datasource to use. Default value is java:/HypericDS
+ * JNDI name of the datasource to use. Default value is java:/jboss/datasources/RHQDS
* </pre>
*/
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java
index 5640f3f..2b761f6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/JDBCPrincipalCheckLoginModule.java
@@ -38,6 +38,7 @@ import org.apache.commons.logging.LogFactory;
import org.jboss.crypto.CryptoUtil;
import org.jboss.security.SimpleGroup;
+import org.jboss.security.SimplePrincipal;
import org.jboss.security.auth.spi.UsernamePasswordLoginModule;
import org.rhq.enterprise.server.RHQConstants;
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
index e476eeb..6b7add6 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/core/jaas/LdapLoginModule.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2008 Red Hat, Inc.
+ * Copyright (C) 2005-2013 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -13,8 +13,8 @@
* 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.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.server.core.jaas;
@@ -42,8 +42,8 @@ import org.rhq.enterprise.server.util.LookupUtil;
import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
/**
- * A login module for authenticating against an LDAP directory server using JNDI, based on configuration properites LDAP
- * module options:
+ * A login module for authenticating against an LDAP directory server using JNDI, based on configuration properties.<br/
+ * LDAP module options:
*
* <pre>
* java.naming.factory.initial
@@ -72,7 +72,7 @@ import org.rhq.enterprise.server.util.security.UntrustedSSLSocketFactory;
* BaseDN
* The base of the LDAP tree we are authenticating against. For example:
* o=Covalent Technologies,c=US. Multiple LDAP bases can be used by
- * seperating each DN by ';'
+ * separating each DN by ';'
*
* BindDN
* The BindDN to use if the LDAP server does not support anonymous searches.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
index 52cd33d..de3b836 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/system/SystemManagerBean.java
@@ -464,7 +464,7 @@ public class SystemManagerBean implements SystemManagerLocal, SystemManagerRemot
}
} else if (property == SystemSetting.AGENT_MAX_QUIET_TIME_ALLOWED) {
long time = Long.parseLong(value);
- // minimum should be 3 * the agent ping interval, any less risks unwanted backfilling
+ // minimum should be 3 * the agent ping interval, any less risks unwanted backfilling
if (time < 1000L * 60 * 3) {
throw new InvalidSystemConfigurationException("Agent Max Quiet Time Allowed must be at least 3 minutes");
}
commit b9ce1ee3cc01fd2bf5614f10e164a1f4cebfe42c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu May 16 13:11:14 2013 -0400
BZ 957282 957288 add bundle target of "Base Directory"
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 4a26d19..ad22370 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -1337,6 +1337,10 @@
<value-context>pluginConfiguration</value-context>
<value-name>homeDir</value-name>
</destination-base-dir>
+ <destination-base-dir name="Base Directory" description="The base directory for server content, such as '[install-dir]/standalone' (i.e. the value found in the 'Base Directory' connection property)">
+ <value-context>pluginConfiguration</value-context>
+ <value-name>baseDir</value-name>
+ </destination-base-dir>
<destination-base-dir name="Deploy Directory" description="The deployment directory for a standalone server">
<value-context>measurementTrait</value-context>
<value-name>deployDir</value-name>
commit f9052819e3da19359081274d62eb6b0f75dd63e2
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Thu May 16 14:28:01 2013 +0200
Bug 962787 - GloballyUncaughtException when changing a parameter in Connection Settings tab of a compatible group after a plugin update
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
index 8b5be2c..b3ccb10 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/configuration/GroupConfigurationEditor.java
@@ -1,8 +1,7 @@
/*
* RHQ Management Platform
- * Copyright 2010-2011, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
+ * 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
@@ -14,8 +13,8 @@
* 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.
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
package org.rhq.enterprise.gui.coregui.client.components.configuration;
@@ -71,10 +70,10 @@ import org.rhq.enterprise.gui.coregui.client.ImageManager;
import org.rhq.enterprise.gui.coregui.client.PopupWindow;
import org.rhq.enterprise.gui.coregui.client.components.form.SortedSelectItem;
import org.rhq.enterprise.gui.coregui.client.util.StringUtility;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedToolStrip;
import org.rhq.enterprise.gui.coregui.client.util.enhanced.EnhancedVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message.Severity;
/**
* A SmartGWT widget for editing a group of RHQ {@link Configuration}s that conform to the same
@@ -638,28 +637,20 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
}
private Property getProperty(Configuration configuration, Property referenceProperty, Integer index) {
- LinkedList<Property> propertyHierarchy = new LinkedList<Property>();
- Property currentProperty = referenceProperty;
- propertyHierarchy.add(currentProperty);
- do {
- if (currentProperty.getParentMap() != null) {
- currentProperty = currentProperty.getParentMap();
- } else if (currentProperty.getParentList() != null) {
- currentProperty = currentProperty.getParentList();
- } else if (currentProperty.getConfiguration() == null) {
- throw new IllegalStateException(currentProperty + " has no parent.");
- }
- propertyHierarchy.addFirst(currentProperty);
- } while (currentProperty.getConfiguration() == null);
-
- Property property = configuration.get(propertyHierarchy.get(0).getName());
- for (int i = 1, propertyHierarchySize = propertyHierarchy.size(); i < propertyHierarchySize; i++) {
- String childPropertyName = propertyHierarchy.get(i).getName();
+ List<Property> referenceHierarchy = getParentFirstPropertiesHierarchy(referenceProperty);
+ // Add referenceProperty to the configuration, creating parents if necessary
+ Property property = configuration.get(referenceHierarchy.get(0).getName());
+ if (property == null) {
+ property = createPropertyByExample(referenceHierarchy.get(0));
+ configuration.put(property);
+ }
+ for (int i = 1; i < referenceHierarchy.size(); i++) {
+ String childPropertyName = referenceHierarchy.get(i).getName();
if (property instanceof PropertyMap) {
PropertyMap propertyMap = (PropertyMap) property;
property = propertyMap.get(childPropertyName);
if (property == null) {
- property = new PropertySimple(childPropertyName, null);
+ property = createPropertyByExample(referenceHierarchy.get(i));
propertyMap.put(property);
}
} else if (property instanceof PropertyList) {
@@ -667,7 +658,7 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
if (index < propertyList.getList().size()) {
property = propertyList.getList().get(index);
} else {
- property = new PropertySimple(childPropertyName, null);
+ property = createPropertyByExample(referenceHierarchy.get(i));
propertyList.add(property);
}
}
@@ -676,6 +667,35 @@ public class GroupConfigurationEditor extends ConfigurationEditor {
return property;
}
+ private List<Property> getParentFirstPropertiesHierarchy(Property bottomProperty) {
+ LinkedList<Property> propertyHierarchy = new LinkedList<Property>();
+ for (Property currentProperty = bottomProperty; currentProperty != null; ) {
+ propertyHierarchy.addFirst(currentProperty);
+ if (currentProperty.getParentMap() != null) {
+ currentProperty = currentProperty.getParentMap();
+ } else if (currentProperty.getParentList() != null) {
+ currentProperty = currentProperty.getParentList();
+ } else if (currentProperty.getConfiguration() == null) {
+ throw new IllegalStateException(currentProperty + " has no parent.");
+ } else {
+ currentProperty = null;
+ }
+ }
+ return new ArrayList<Property>(propertyHierarchy);
+ }
+
+ private <T extends Property> T createPropertyByExample(T example) {
+ T property = null;
+ if (example instanceof PropertyMap) {
+ property = (T) new PropertyMap(example.getName());
+ } else if (example instanceof PropertyList) {
+ property = (T) new PropertyList(example.getName());
+ } else {
+ property = (T) new PropertySimple(example.getName(), null);
+ }
+ return property;
+ }
+
private boolean isAggregateProperty(PropertySimple propertySimple) {
return (getConfiguration(propertySimple) == getConfiguration());
}
commit ac38cd855156fd93958f82b40ca5cf75a3f6593d
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed May 15 17:13:18 2013 -0400
BZ 951382 - for upgrades, let's use the agent preferences upgrade feature
to set the cert store locations explicitly and copy the files
from data/ to conf/ which is the new default location. Note that if
customers already explicitly set the locations of their cert stores,
we leave those intact and continue using what the customer asked to use.
We only do anything IF those settings weren't set and thus defaults
were taking effect.
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java
index 4fe7df9..3f9a89b 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationConstants.java
@@ -58,7 +58,7 @@ public interface AgentConfigurationConstants {
/**
* This is the current schema version that our agent configuration knows about.
*/
- int CURRENT_CONFIG_SCHEMA_VERSION = 6;
+ int CURRENT_CONFIG_SCHEMA_VERSION = 7;
/**
* Flag to indicate if the agent's configuration has been setup.
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationUpgrade.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationUpgrade.java
index 6c0a2ce..27e68f9 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationUpgrade.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentConfigurationUpgrade.java
@@ -18,10 +18,17 @@
*/
package org.rhq.enterprise.agent;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.prefs.Preferences;
+import mazz.i18n.Logger;
+
+import org.rhq.core.util.file.FileUtil;
+import org.rhq.enterprise.agent.i18n.AgentI18NFactory;
+import org.rhq.enterprise.agent.i18n.AgentI18NResourceKeys;
+import org.rhq.enterprise.communications.ServiceContainerConfigurationConstants;
import org.rhq.enterprise.communications.util.prefs.PreferencesUpgrade;
import org.rhq.enterprise.communications.util.prefs.PreferencesUpgradeStep;
@@ -31,6 +38,8 @@ import org.rhq.enterprise.communications.util.prefs.PreferencesUpgradeStep;
* @author John Mazzitelli
*/
public class AgentConfigurationUpgrade extends PreferencesUpgrade {
+ private static final Logger LOG = AgentI18NFactory.getLogger(AgentConfigurationUpgrade.class);
+
/**
* This is a convenience method that upgrades the given agent preferences to the latest configuration schema
* version.
@@ -58,7 +67,8 @@ public class AgentConfigurationUpgrade extends PreferencesUpgrade {
list.add(new Step2to3()); // goes from v2 to v3
list.add(new Step3to4()); // goes from v3 to v4
list.add(new Step4to5()); // goes from v4 to v5
- list.add(new Step5to6());
+ list.add(new Step5to6()); // goes from v5 to v6
+ list.add(new Step6to7()); // goes from v6 to v7
return list;
}
@@ -139,4 +149,55 @@ public class AgentConfigurationUpgrade extends PreferencesUpgrade {
preferences.put(AgentConfigurationConstants.SERVER_ALIAS, "rhqserver");
}
}
+
+ static class Step6to7 extends PreferencesUpgradeStep {
+ public int getSupportedConfigurationSchemaVersion() {
+ return 7;
+ }
+
+ public void upgrade(Preferences preferences) {
+ // This new schema version indicates when we changed the default locations for our keystore/truststore
+ // files. Before if these comm settings weren't set, we assumed a default of "data" directory, but now
+ // we assume a default of "conf" directory (if that directory exists). See BZ 951382.
+ File confDir = new File("conf");
+ if (!confDir.exists()) {
+ return; // conf/ doesn't exist (perhaps we are running in a test?) - do nothing and just fallback to the standard defaults
+ }
+
+ String dataDir = preferences.get(AgentConfigurationConstants.DATA_DIRECTORY,
+ AgentConfigurationConstants.DEFAULT_DATA_DIRECTORY);
+
+ String prefNamesFileNames[][] = {
+ { ServiceContainerConfigurationConstants.CONNECTOR_SECURITY_KEYSTORE_FILE,
+ ServiceContainerConfigurationConstants.DEFAULT_CONNECTOR_SECURITY_KEYSTORE_FILE_NAME },
+ { ServiceContainerConfigurationConstants.CONNECTOR_SECURITY_TRUSTSTORE_FILE,
+ ServiceContainerConfigurationConstants.DEFAULT_CONNECTOR_SECURITY_TRUSTSTORE_FILE_NAME },
+ { AgentConfigurationConstants.CLIENT_SENDER_SECURITY_KEYSTORE_FILE,
+ AgentConfigurationConstants.DEFAULT_CLIENT_SENDER_SECURITY_KEYSTORE_FILE_NAME },
+ { AgentConfigurationConstants.CLIENT_SENDER_SECURITY_TRUSTSTORE_FILE,
+ AgentConfigurationConstants.DEFAULT_CLIENT_SENDER_SECURITY_TRUSTSTORE_FILE_NAME } };
+
+ for (String[] prefNameFileName : prefNamesFileNames) {
+ String value = preferences.get(prefNameFileName[0], null);
+ if (value == null) {
+ File newFile = new File(confDir, prefNameFileName[1]);
+ value = newFile.getAbsolutePath();
+ preferences.put(prefNameFileName[0], value);
+
+ File oldFile = new File(dataDir, prefNameFileName[1]);
+ if (oldFile.exists()) {
+ try {
+ FileUtil.copyFile(oldFile, newFile);
+ oldFile.delete();
+ } catch (Exception e) {
+ LOG.error(e, AgentI18NResourceKeys.CERT_FILE_COPY_ERROR, oldFile, newFile);
+ }
+ }
+ LOG.debug(AgentI18NResourceKeys.CERT_FILE_LOCATION, prefNameFileName[0], value);
+ }
+ }
+
+ return;
+ }
+ }
}
\ No newline at end of file
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java
index 21a39a9..16c110a 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/i18n/AgentI18NResourceKeys.java
@@ -28,6 +28,9 @@ import mazz.i18n.annotation.I18NResourceBundle;
*/
@I18NResourceBundle(baseName = "agent-messages", defaultLocale = "en")
public interface AgentI18NResourceKeys {
+ @I18NMessage("Failed to move old cert file [{0}] to new default location [{1}] - agent communication may fail!")
+ String CERT_FILE_COPY_ERROR = "AgentConfiguration.cert-file-copy-error";
+
@I18NMessage("Explicitly setting file location [{0}] to [{1}]")
String CERT_FILE_LOCATION = "AgentConfiguration.cert-file-location";
commit 3034e3c906a352723834aa4adce41355d7310bce
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed May 15 12:30:18 2013 -0400
provide another sample plugin that demonstrates using the embedded plugin extension model
diff --git a/.classpath b/.classpath
index aa4c157..53037dd 100644
--- a/.classpath
+++ b/.classpath
@@ -189,6 +189,8 @@
<classpathentry kind="src" path="modules/integration-tests/jndi-access/jndi-access-test/src/test/resources"/>
<classpathentry kind="src" path="modules/integration-tests/mod_cluster-plugin-test/src/test/java"/>
<classpathentry kind="src" path="etc/samples/skeleton-plugin/src/main/java"/>
+ <classpathentry kind="src" path="etc/samples/embedded-ext-plugin/src/main/java"/>
+ <classpathentry kind="src" path="etc/samples/skinny-platform/src/main/java"/>
<classpathentry kind="src" path="etc/samples/custom-serverplugin/src/main/java"/>
<classpathentry kind="src" path="etc/samples/simplereport-serverplugin/src/main/java"/>
<classpathentry kind="src" path="etc/agentspawn/src/main/java"/>
diff --git a/etc/samples/embedded-ext-plugin/pom.xml b/etc/samples/embedded-ext-plugin/pom.xml
new file mode 100644
index 0000000..9427d71
--- /dev/null
+++ b/etc/samples/embedded-ext-plugin/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0"?>
+
+<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>
+
+ <groupId>org.rhq.sample.embeddedextplugin</groupId>
+ <artifactId>embedded-ext-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Embedded Ext RHQ Plugin</name>
+ <description>A sample plugin showing plugin embedded extention</description>
+
+ <properties>
+ <rhq.version>4.8.0-SNAPSHOT</rhq.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-plugin-api</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-native-system</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq.sample.skeletonplugin</groupId>
+ <artifactId>skeleton-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
+
diff --git a/etc/samples/embedded-ext-plugin/src/main/java/org/rhq/sample/embeddedextplugin/EmbeddedExtensionDiscoveryComponent.java b/etc/samples/embedded-ext-plugin/src/main/java/org/rhq/sample/embeddedextplugin/EmbeddedExtensionDiscoveryComponent.java
new file mode 100644
index 0000000..6e823c3
--- /dev/null
+++ b/etc/samples/embedded-ext-plugin/src/main/java/org/rhq/sample/embeddedextplugin/EmbeddedExtensionDiscoveryComponent.java
@@ -0,0 +1,58 @@
+/*
+ * 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.sample.embeddedextplugin;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+import org.rhq.sample.skeletonplugin.SamplePluginDiscoveryComponent;
+
+/**
+ * This is a discovery class for the embedded extension resource type.
+ */
+public class EmbeddedExtensionDiscoveryComponent extends SamplePluginDiscoveryComponent {
+ private final Log log = LogFactory.getLog(EmbeddedExtensionDiscoveryComponent.class);
+
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+ log.info("Discovering embedded extension resources");
+ Set<DiscoveredResourceDetails> discoveredResources = super.discoverResources(context); // call the parent discovery code
+ Set<DiscoveredResourceDetails> extendedResources = new HashSet<DiscoveredResourceDetails>();
+
+ int i = -1;
+ for (DiscoveredResourceDetails discoveredResource : discoveredResources) {
+ String key = "Embedded Extension Resource Key" + (++i > 0 ? String.valueOf(i) : "");
+ String name = "Embedded Extension Resource";
+ String description = "This describes the Embedded Extension Resource";
+
+ discoveredResource.setResourceKey(key);
+ discoveredResource.setResourceName(name);
+ discoveredResource.setResourceDescription(description);
+
+ extendedResources.add(discoveredResource);
+ }
+
+ return extendedResources;
+ }
+}
\ No newline at end of file
diff --git a/etc/samples/embedded-ext-plugin/src/main/resources/META-INF/rhq-plugin.xml b/etc/samples/embedded-ext-plugin/src/main/resources/META-INF/rhq-plugin.xml
new file mode 100644
index 0000000..16dbb7b
--- /dev/null
+++ b/etc/samples/embedded-ext-plugin/src/main/resources/META-INF/rhq-plugin.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<plugin name="EmbeddedExtPlugin"
+ displayName="Embedded Extension Plugin"
+ version="1.0"
+ package="org.rhq.sample.embeddedextplugin"
+ description="Defines a resource type that uses the embedded extension model."
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <depends plugin="SkeletonPlugin" useClasses="true" />
+
+ <server name="Embedded Extension Resource"
+ discovery="EmbeddedExtensionDiscoveryComponent"
+ class="org.rhq.sample.skeletonplugin.SamplePluginServerComponent"
+ description="A resource that embeds the skeleton plugin type"
+ sourcePlugin="SkeletonPlugin"
+ sourceType="Sample Plugin Server">
+ </server>
+
+</plugin>
commit 8cbe5ffb7379c26403f9083bc7b0642f490ff9eb
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed May 15 11:47:55 2013 -0400
provide some additions to the sample skeleton plugin
add a new "skinny platform" plugin sample, used mainly for testing - provides a minimal plugin you can use to run an agent with
diff --git a/etc/samples/skeleton-plugin/pom.xml b/etc/samples/skeleton-plugin/pom.xml
index 56c816e..998bb47 100644
--- a/etc/samples/skeleton-plugin/pom.xml
+++ b/etc/samples/skeleton-plugin/pom.xml
@@ -15,7 +15,7 @@
<description>A template for building a custom RHQ Agent plugin</description>
<properties>
- <rhq.version>4.3.0</rhq.version>
+ <rhq.version>4.8.0-SNAPSHOT</rhq.version>
</properties>
<dependencies>
@@ -42,30 +42,6 @@
<scope>provided</scope> <!-- provided by the agent/plugin-container -->
</dependency>
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>javax.persistence</groupId>
- <artifactId>persistence-api</artifactId>
- <version>1.0</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>hibernate-annotations</groupId>
- <artifactId>hibernate-annotations</artifactId>
- <version>3.2.1.GA</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
- <!-- Fix for the Javac bug requiring annotations to be available when compiling classes. (fixed in JDK 6) -->
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>2.1</version>
- <scope>provided</scope> <!-- provided by the agent/plugin-container -->
- </dependency>
-
<!--
Uncomment the one of the three logging systems your plugin uses: log4j, commons-logging or i18nlog
All three are provided to your plugin by the agent/plugin-container.
@@ -143,79 +119,6 @@
</plugins>
</build>
- <profiles>
- <profile>
- <id>dev</id>
- <properties>
- <!-- define the location of your RHQ root directory - typically rhq.rootDir is overridden in Maven's settings.xml -->
- <rhq.rootDir>/rhq/trunk</rhq.rootDir>
- <rhq.defaultDevContainerPath>dev-container</rhq.defaultDevContainerPath>
- <rhq.containerDir>${rhq.rootDir}/${rhq.defaultDevContainerPath}</rhq.containerDir>
- <rhq.deploymentDir>${rhq.containerDir}/${rhq.agentPluginDir}</rhq.deploymentDir>
- </properties>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <id>deploy</id>
- <phase>compile</phase>
- <configuration>
- <target>
- <mkdir dir="${rhq.deploymentDir}" />
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating ${deployment.file}...</echo>
- <jar destfile="${deployment.file}" basedir="${project.build.outputDirectory}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>deploy-jar-meta-inf</id>
- <phase>package</phase>
- <configuration>
- <target>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Updating META-INF dir in ${deployment.file}...</echo>
- <unjar src="${project.build.directory}/${project.build.finalName}.jar" dest="${project.build.outputDirectory}">
- <patternset>
- <include name="META-INF/**" />
- </patternset>
- </unjar>
- <jar destfile="${deployment.file}"
- manifest="${project.build.outputDirectory}/META-INF/MANIFEST.MF"
- update="true">
- </jar>
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- <execution>
- <id>undeploy</id>
- <phase>clean</phase>
- <configuration>
- <target>
- <property name="deployment.file" location="${rhq.deploymentDir}/${project.build.finalName}.jar" />
- <echo>*** Deleting ${deployment.file}...</echo>
- <delete file="${deployment.file}" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
<repositories>
<repository>
<id>jboss-public-repository-group</id>
diff --git a/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildDiscoveryComponent.java b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildDiscoveryComponent.java
new file mode 100644
index 0000000..b8a81ab
--- /dev/null
+++ b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildDiscoveryComponent.java
@@ -0,0 +1,47 @@
+/*
+ * 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.sample.skeletonplugin;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+public class SamplePluginChildDiscoveryComponent implements ResourceDiscoveryComponent {
+ private final Log log = LogFactory.getLog(SamplePluginChildDiscoveryComponent.class);
+
+ @Override
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+ log.info("Discovering my custom plugin's child resources");
+ HashSet<DiscoveredResourceDetails> set = new HashSet<DiscoveredResourceDetails>();
+ String key = "My Child Resource Key";
+ String name = "My Child Resource";
+ String version = "1.0";
+ String description = "This describes My Child Resource";
+ DiscoveredResourceDetails resource = new DiscoveredResourceDetails(context.getResourceType(), key, name,
+ version, description, null, null);
+ set.add(resource);
+ return set;
+ }
+}
\ No newline at end of file
diff --git a/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildServiceComponent.java b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildServiceComponent.java
new file mode 100644
index 0000000..a3303e7
--- /dev/null
+++ b/etc/samples/skeleton-plugin/src/main/java/org/rhq/sample/skeletonplugin/SamplePluginChildServiceComponent.java
@@ -0,0 +1,61 @@
+/*
+ * 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.sample.skeletonplugin;
+
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.domain.measurement.MeasurementDataNumeric;
+import org.rhq.core.domain.measurement.MeasurementReport;
+import org.rhq.core.domain.measurement.MeasurementScheduleRequest;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+import org.rhq.core.pluginapi.measurement.MeasurementFacet;
+
+public class SamplePluginChildServiceComponent implements ResourceComponent, MeasurementFacet {
+ private final Log log = LogFactory.getLog(SamplePluginChildServiceComponent.class);
+
+ public void start(ResourceContext context) {
+ log.info("Starting child resource [" + context.getResourceKey() + "]");
+ }
+
+ public void stop() {
+ }
+
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP;
+ }
+
+ public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
+ for (MeasurementScheduleRequest request : requests) {
+ String name = request.getName();
+ try {
+ Number value = new Integer(2); // dummy measurement value
+ report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
+ } catch (Exception e) {
+ log.error("Failed to obtain measurement [" + name + "]. Cause: " + e);
+ }
+ }
+
+ return;
+ }
+}
diff --git a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
index 4f4966d..cde11c5 100644
--- a/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
+++ b/etc/samples/skeleton-plugin/src/main/resources/META-INF/rhq-plugin.xml
@@ -15,6 +15,7 @@
<plugin name="SkeletonPlugin"
displayName="Skeleton Plugin"
version="1.0"
+ description="This is a skeleton plugin that can be used to start your own custom plugin."
package="org.rhq.sample.skeletonplugin"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="urn:xmlns:rhq-plugin"
@@ -110,5 +111,24 @@
<resource-configuration>
<c:simple-property name="port" type="integer" displayName="Port on which to listen" />
</resource-configuration>
+
+ <!--
+ CHANGE: You can optionally define children resource types to represent internal services within your
+ server resource type.
+ -->
+ <service name="Sample Plugin Child Service"
+ discovery="SamplePluginChildDiscoveryComponent"
+ class="SamplePluginChildServiceComponent"
+ description="This is a child service found under the main, top-level server resource type.">
+
+ <plugin-configuration>
+ <c:simple-property name="SamplePluginChildProperty" displayName="Sample Plugin Child Property" default="Value" />
+ </plugin-configuration>
+
+ <metric property="ChildMeasurementName"
+ displayName="The Child Measurement Name"
+ description="Describes what this child measurement is actually telling you" />
+
+ </service>
</server>
</plugin>
diff --git a/etc/samples/skinny-platform/pom.xml b/etc/samples/skinny-platform/pom.xml
new file mode 100644
index 0000000..994462f
--- /dev/null
+++ b/etc/samples/skinny-platform/pom.xml
@@ -0,0 +1,60 @@
+<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>
+
+ <groupId>org.rhq.sample.skinnyplugin</groupId>
+ <artifactId>rhq-skinny-platform-plugin</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>RHQ Skinny Platform Plugin</name>
+ <description> A very slimmed down platform plugin, used for testing.</description>
+
+ <properties>
+ <rhq.version>4.8.0-SNAPSHOT</rhq.version>
+ </properties>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-domain</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-plugin-api</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
+ <artifactId>rhq-core-native-system</artifactId>
+ <version>${rhq.version}</version>
+ <scope>provided</scope> <!-- provided by the agent/plugin-container -->
+ </dependency>
+
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+ <url>https://repository.jboss.org/nexus/content/groups/public/</url>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+</project>
diff --git a/etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformComponent.java b/etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformComponent.java
new file mode 100644
index 0000000..0c123b1
--- /dev/null
+++ b/etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformComponent.java
@@ -0,0 +1,39 @@
+/*
+ * 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, 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.plugins.skinnyplatform;
+
+import org.rhq.core.domain.measurement.AvailabilityType;
+import org.rhq.core.pluginapi.inventory.ResourceComponent;
+import org.rhq.core.pluginapi.inventory.ResourceContext;
+
+public class PlatformComponent implements ResourceComponent<PlatformComponent> {
+ public void start(ResourceContext<PlatformComponent> context) {
+ }
+
+ public void stop() {
+ }
+
+ public AvailabilityType getAvailability() {
+ return AvailabilityType.UP;
+ }
+}
\ No newline at end of file
diff --git a/etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformDiscoveryComponent.java b/etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformDiscoveryComponent.java
new file mode 100644
index 0000000..b53b1c3
--- /dev/null
+++ b/etc/samples/skinny-platform/src/main/java/org/rhq/plugins/skinnyplatform/PlatformDiscoveryComponent.java
@@ -0,0 +1,67 @@
+/*
+ * 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, 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.plugins.skinnyplatform;
+
+import java.net.InetAddress;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryComponent;
+import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
+
+@SuppressWarnings("rawtypes")
+public class PlatformDiscoveryComponent implements ResourceDiscoveryComponent {
+
+ public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
+ String pcName = context.getPluginContainerName();
+ String hostname = getHostname();
+
+ String name = (pcName != null ? pcName : hostname);
+ String key = "skinny:" + name;
+ String description = context.getResourceType().getDescription();
+ String version = "1.0";
+
+ DiscoveredResourceDetails discoveredResource = new DiscoveredResourceDetails(context.getResourceType(), key,
+ name, version, description, null, null);
+
+ HashSet<DiscoveredResourceDetails> results = new HashSet<DiscoveredResourceDetails>();
+ results.add(discoveredResource);
+ return results;
+ }
+
+ private String getHostname() {
+ String name;
+ try {
+ name = InetAddress.getLocalHost().getHostAddress();
+ } catch (Exception e) {
+ name = null;
+ }
+
+ // we fought the good fight but we just can't get this machine's hostname, give a generic platform name
+ if (name == null) {
+ name = "Unnamed Skinny Platform";
+ }
+ return name;
+ }
+}
\ No newline at end of file
diff --git a/etc/samples/skinny-platform/src/main/resources/META-INF/rhq-plugin.xml b/etc/samples/skinny-platform/src/main/resources/META-INF/rhq-plugin.xml
new file mode 100644
index 0000000..fd50a2a
--- /dev/null
+++ b/etc/samples/skinny-platform/src/main/resources/META-INF/rhq-plugin.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<plugin name="Skinny Platform"
+ displayName="Skinny Platform"
+ version="1.0"
+ package="org.rhq.plugins.skinnyplatform"
+ description="Provides a slimmed down, single platform resource type - used mainly for testing."
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns="urn:xmlns:rhq-plugin"
+ xmlns:c="urn:xmlns:rhq-configuration">
+
+ <platform name="Generic Platform"
+ class="PlatformComponent"
+ discovery="PlatformDiscoveryComponent"
+ description="A generic platform with very little functionality.">
+ </platform>
+
+</plugin>
commit 98cb0afd7a2bcfcb8f74f3d8182fb9798edd2b49
Author: mtho11 <mikecthompson(a)gmail.com>
Date: Tue May 14 10:38:22 2013 -0700
[BZ 960646] - Trivial: strengthen opacity on new Availability chart.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java
index 5ef57a8..a301e73 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java
@@ -243,7 +243,7 @@ public class AvailabilityOverUnderGraphType {
.attr("width", function (d) {
return timeScale(+d.availEnd) - timeScale(+d.availStart);
})
- .attr("opacity", ".3")
+ .attr("opacity", ".75")
.attr("fill", function (d) {
return calcBarFill(d);
});
@@ -265,7 +265,7 @@ public class AvailabilityOverUnderGraphType {
.style("font-size", "12px")
.style("font-family", "Arial, Verdana, sans-serif;")
.style("font-weight", "bold")
- .attr("fill", "#003168")
+ .attr("fill", "#545454")
.text(availChartContext.chartTitle);
svg.append("text")
commit cf37517727392d04d8ab11182fd94474571462d8
Author: mtho11 <mikecthompson(a)gmail.com>
Date: Tue May 14 09:20:26 2013 -0700
[BZ 960646] - UXD updates to new Availability Charts.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java
index fbce610..5ef57a8 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AvailabilityOverUnderGraphType.java
@@ -169,9 +169,9 @@ public class AvailabilityOverUnderGraphType {
.orient("bottom"),
calcBarY = function (d) {
- var ABOVE = -10,
+ var ABOVE = -6,
BELOW = 0,
- STRADDLE = -5,
+ STRADDLE = -3,
offset;
if (d.availType === 'DOWN') {
@@ -198,19 +198,19 @@ public class AvailabilityOverUnderGraphType {
calcBarFill = function (d) {
if (d.availType === 'DOWN') {
- return "#FF1919"; // red
+ return "#c5888b"; // red
}
else if (d.availType === 'DISABLED') {
return "url(#diagonalHatchFill)"; // grey diagonal hatches
}
else if (d.availType === 'UNKNOWN') {
- return "#CCC"; // gray
+ return "#d8d8d8"; // gray
}
else if (d.availType === 'UP') {
- return "#198C19"; // green
+ return "#8cbe89"; // green
}
else if (d.availType === 'WARN') {
- return "#FFA500"; // orange
+ return "#e1b36b"; // orange
}
else if (d.availType === 'EMPTY') {
return "#CCC"; // gray
@@ -238,12 +238,12 @@ public class AvailabilityOverUnderGraphType {
return calcBarY(d);
})
.attr("height", function (d) {
- return 10;
+ return 6;
})
.attr("width", function (d) {
return timeScale(+d.availEnd) - timeScale(+d.availStart);
})
- .attr("opacity", ".9")
+ .attr("opacity", ".3")
.attr("fill", function (d) {
return calcBarFill(d);
});
@@ -251,7 +251,7 @@ public class AvailabilityOverUnderGraphType {
// create x-axis
svg.append("g")
.attr("class", "x axis")
- .attr("fill", "#50505a")
+ .attr("fill", "#b0b0b0")
.attr("stroke-width", "0.5")
.attr("transform", "translate(0," + height + ")")
.attr("letter-spacing", "3")
@@ -274,7 +274,7 @@ public class AvailabilityOverUnderGraphType {
.attr("y", 28)
.style("font-family", "Arial, Verdana, sans-serif;")
.style("font-size", "9px")
- .attr("fill", "#50505a")
+ .attr("fill", "#545454")
.style("text-anchor", "end")
.text(availChartContext.chartUpLabel);
@@ -284,7 +284,7 @@ public class AvailabilityOverUnderGraphType {
.attr("y", 39)
.style("font-family", "Arial, Verdana, sans-serif;")
.style("font-size", "9px")
- .attr("fill", "#50505a")
+ .attr("fill", "#545454")
.style("text-anchor", "end")
.text(availChartContext.chartDownLabel);
commit af1fdd5d865ab295969f80949b36c3c38c70ccef
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Tue May 14 13:21:44 2013 +0200
Fixing a typo in a sample CLI script.
diff --git a/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js b/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js
index 9739cb1..a965edf 100644
--- a/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js
+++ b/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js
@@ -146,7 +146,7 @@ function _restartFunction(asResourceType) {
(asResourceType.name == "JBossAS7 Standalone Server" ||
asResourceType.name == "Managed Server")) {
- return _restartAS7);
+ return _restartAS7;
} else {
throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
}
commit 9a3b4d105099320c6c6794ff04e12285c5399667
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu May 9 15:15:02 2013 +0200
[BZ 620603] - Re-enabling the limited JOIN FETCH reporting
with a more informative message, asking the users to co-operate in
identifying the individual uses of the problematic JOIN FETCH queries that
we potentially missed.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
index f826e41..8eb4b3e 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
@@ -15,8 +15,8 @@ import org.hibernate.event.spi.EventSource;
import org.hibernate.hql.internal.ast.QueryTranslatorImpl;
/**
- * This class can be used to quickly identify and analyze usages of JOIN FETCH together with limits on JPA queries.
- * It will log the JPA, generated SQL and a filtered stacktrace for each such usage. This is to enhance the diagnostics
+ * This class can be used to quickly identify and analyze usages of JOIN FETCH together with limits on JPA queries. It
+ * will log the JPA, generated SQL and a filtered stacktrace for each such usage. This is to enhance the diagnostics
* that Hibernate itself offers that merely dumps a message about in-memory filtering of results resulting from the use
* of JOIN FETCH together with limits.
*
@@ -24,7 +24,7 @@ import org.hibernate.hql.internal.ast.QueryTranslatorImpl;
*/
public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
- private static Log LOG = LogFactory.getLog("JOIN FETCH Perf");
+ private static Log LOG = LogFactory.getLog("JOIN FETCH Performance");
public JoinFetchReportingQueryTranslator(String queryIdentifier, String query, Map enabledFilters,
SessionFactoryImplementor factory) {
@@ -49,11 +49,14 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
}
}
- public void report() {
+ public void report(String method) {
if (time != 0) {
time = System.currentTimeMillis() - time;
- LOG.warn("List with first: " + firstRow + ", max: " + maxRows + " took " + time + "ms:\n" +
- getQueryString() + "\n\nSQL:\n" + getSQLString() + "\n" + extractRHQCalls(new Exception()));
+ LOG.warn("Encountered a query with potentially bad performance. While this is not a bug and the " +
+ "system functions as designed, please report this to RHQ community so that we can reimplement our" +
+ " code to work better.\n" + method + "() with first: " + firstRow + ", max: " + maxRows + " took "
+ + time + "ms:\n" + getQueryString() + "\n\nSQL:\n" + getSQLString() + "\n" +
+ extractRHQCalls(new Exception()));
}
}
@@ -80,7 +83,7 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
List ret = super.list(session, queryParameters);
- usage.report();
+ usage.report("list");
return ret;
}
@@ -91,7 +94,7 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
Iterator ret = super.iterate(queryParameters, session);
- usage.report();
+ usage.report("iterate");
return ret;
}
@@ -103,7 +106,7 @@ public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
ScrollableResults ret = super.scroll(queryParameters, session);
- usage.report();
+ usage.report("scroll");
return ret;
}
diff --git a/modules/core/domain/src/main/resources/META-INF/persistence.xml b/modules/core/domain/src/main/resources/META-INF/persistence.xml
index a15fd2e..1bbd8c2 100644
--- a/modules/core/domain/src/main/resources/META-INF/persistence.xml
+++ b/modules/core/domain/src/main/resources/META-INF/persistence.xml
@@ -21,9 +21,7 @@
<!--<property name="com.intellij.javaee.persistence.datasource" value="rhq-oracle" />-->
<property name="com.intellij.javaee.persistence.datasource" value="rhq-postgres" />
- <!-- Used only for debugging the usages of JOIN FETCHes
<property name="hibernate.query.factory_class" value="org.rhq.core.domain.util.JoinFetchReportingQueryTranslatorFactory" />
- -->
<!-- This value doesn't have any theoretical grounds and is purely based on experiments. Value of 32 gives
the best compromise between the quick load of queries with low and high limits (i.e. page size in tens vs.
commit db62629626fdd9049cf89cfa58dc5b14b2a98ea9
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu May 9 13:11:50 2013 +0200
[BZ 620603] - Don't use JOIN FETCH in criteria queries with limits.
Use the "manual" initialization of lazy fields and collections in
that case instead.
Together with the "hibernate.default_batch_fetch_size" setting in the
hibernate configuration, this offers superior performance over the join
fetch and in memory filtering of results when the number of rows in the
"primary" tables times the number of rows in the "join-fetched" table
is non-trivial.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
new file mode 100644
index 0000000..f826e41
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
@@ -0,0 +1,110 @@
+package org.rhq.core.domain.util;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.hibernate.HibernateException;
+import org.hibernate.ScrollableResults;
+import org.hibernate.engine.spi.QueryParameters;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.engine.spi.SessionImplementor;
+import org.hibernate.event.spi.EventSource;
+import org.hibernate.hql.internal.ast.QueryTranslatorImpl;
+
+/**
+ * This class can be used to quickly identify and analyze usages of JOIN FETCH together with limits on JPA queries.
+ * It will log the JPA, generated SQL and a filtered stacktrace for each such usage. This is to enhance the diagnostics
+ * that Hibernate itself offers that merely dumps a message about in-memory filtering of results resulting from the use
+ * of JOIN FETCH together with limits.
+ *
+ * @author Lukas Krejci
+ */
+public class JoinFetchReportingQueryTranslator extends QueryTranslatorImpl {
+
+ private static Log LOG = LogFactory.getLog("JOIN FETCH Perf");
+
+ public JoinFetchReportingQueryTranslator(String queryIdentifier, String query, Map enabledFilters,
+ SessionFactoryImplementor factory) {
+ super(queryIdentifier, query, enabledFilters, factory);
+ }
+
+ private class JoinFetchUsage {
+ private long time;
+ private Integer firstRow;
+ private Integer maxRows;
+
+ public JoinFetchUsage(QueryParameters queryParameters) {
+ boolean collect = containsCollectionFetches();
+ boolean hasLimit =
+ queryParameters.getRowSelection() != null && queryParameters.getRowSelection().definesLimits();
+
+ if (collect && hasLimit) {
+ firstRow = queryParameters.getRowSelection().getFirstRow();
+ maxRows = queryParameters.getRowSelection().getMaxRows();
+
+ time = System.currentTimeMillis();
+ }
+ }
+
+ public void report() {
+ if (time != 0) {
+ time = System.currentTimeMillis() - time;
+ LOG.warn("List with first: " + firstRow + ", max: " + maxRows + " took " + time + "ms:\n" +
+ getQueryString() + "\n\nSQL:\n" + getSQLString() + "\n" + extractRHQCalls(new Exception()));
+ }
+ }
+
+ private String extractRHQCalls(Throwable t) {
+ StringBuilder bld = new StringBuilder();
+
+ StackTraceElement[] elements = t.getStackTrace();
+
+ //skip the report() and list() calls, hence 2
+ for (int i = 2; i < elements.length; ++i) {
+ StackTraceElement e = elements[i];
+ if (e.getClassName().startsWith("org.rhq")) {
+ bld.append("\n").append(e.toString());
+ }
+ }
+
+ return bld.toString();
+ }
+ }
+
+ @Override
+ public List list(SessionImplementor session, QueryParameters queryParameters) throws HibernateException {
+ JoinFetchUsage usage = new JoinFetchUsage(queryParameters);
+
+ List ret = super.list(session, queryParameters);
+
+ usage.report();
+
+ return ret;
+ }
+
+ @Override
+ public Iterator iterate(QueryParameters queryParameters, EventSource session) throws HibernateException {
+ JoinFetchUsage usage = new JoinFetchUsage(queryParameters);
+
+ Iterator ret = super.iterate(queryParameters, session);
+
+ usage.report();
+
+ return ret;
+ }
+
+ @Override
+ public ScrollableResults scroll(QueryParameters queryParameters, SessionImplementor session)
+ throws HibernateException {
+ JoinFetchUsage usage = new JoinFetchUsage(queryParameters);
+
+ ScrollableResults ret = super.scroll(queryParameters, session);
+
+ usage.report();
+
+ return ret;
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java
new file mode 100644
index 0000000..71e1bf2
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java
@@ -0,0 +1,27 @@
+package org.rhq.core.domain.util;
+
+import java.util.Map;
+
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.hql.spi.FilterTranslator;
+import org.hibernate.hql.spi.QueryTranslator;
+import org.hibernate.hql.spi.QueryTranslatorFactory;
+
+/**
+ * A query translator factory to be set in the hibernate configuration to report the usage of JOIN FETCH with limit.
+ *
+ * @author Lukas Krejci
+ */
+public class JoinFetchReportingQueryTranslatorFactory implements QueryTranslatorFactory {
+ @Override
+ public QueryTranslator createQueryTranslator(String queryIdentifier, String queryString, Map filters,
+ SessionFactoryImplementor factory) {
+ return new JoinFetchReportingQueryTranslator(queryIdentifier, queryString, filters, factory);
+ }
+
+ @Override
+ public FilterTranslator createFilterTranslator(String queryIdentifier, String queryString, Map filters,
+ SessionFactoryImplementor factory) {
+ return new JoinFetchReportingQueryTranslator(queryIdentifier, queryString, filters, factory);
+ }
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java
index 6963141..f87a814 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/PageControl.java
@@ -276,6 +276,10 @@ public class PageControl implements Serializable, Cloneable {
orderingFields = new LinkedList<OrderingField>();
}
+ public boolean isUnlimited() {
+ return getPageNumber() == 0 && getPageSize() == SIZE_UNLIMITED;
+ }
+
// TODO (ips, 10/12/11): Incorporate firstRecord field into equals() and hashCode().
@Override
@@ -334,4 +338,4 @@ public class PageControl implements Serializable, Cloneable {
return new PageControl(pageNumber, pageSize, getOrderingFieldsAsArray());
}
-}
\ No newline at end of file
+}
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java b/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java
index ce7ab20..af5842a 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/util/UnlimitedPageControl.java
@@ -30,6 +30,11 @@ public class UnlimitedPageControl extends PageControl {
}
@Override
+ public boolean isUnlimited() {
+ return true;
+ }
+
+ @Override
public void reset() {
getOrderingFields().clear();
}
diff --git a/modules/core/domain/src/main/resources/META-INF/persistence.xml b/modules/core/domain/src/main/resources/META-INF/persistence.xml
index 8e28c68..a15fd2e 100644
--- a/modules/core/domain/src/main/resources/META-INF/persistence.xml
+++ b/modules/core/domain/src/main/resources/META-INF/persistence.xml
@@ -20,6 +20,16 @@
<!--<property name="com.intellij.javaee.persistence.datasource" value="rhq-oracle" />-->
<property name="com.intellij.javaee.persistence.datasource" value="rhq-postgres" />
+
+ <!-- Used only for debugging the usages of JOIN FETCHes
+ <property name="hibernate.query.factory_class" value="org.rhq.core.domain.util.JoinFetchReportingQueryTranslatorFactory" />
+ -->
+
+ <!-- This value doesn't have any theoretical grounds and is purely based on experiments. Value of 32 gives
+ the best compromise between the quick load of queries with low and high limits (i.e. page size in tens vs.
+ thousands) in an inventory with 30 agents and >20000 resources. -->
+ <property name="hibernate.default_batch_fetch_size" value="32"/>
+
</properties>
</persistence-unit>
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml
index 9066916..afa622f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/RHQDomain.gwt.xml
@@ -40,10 +40,11 @@
<!-- These classes are overriden for GWT because their original form doesn't gwt-compile. -->
<exclude name="**/ObfuscatedPropertySimple.*"/>
+ <exclude name="**/JoinFetchReporting*.*" />
</source>
<!--<generate-with class="org.rhq.core.rebind.RecordBuilderGenerator">
<when-type-assignable class="org.rhq.core.domain.util.Recordizable"/>
</generate-with>-->
-</module>
\ No newline at end of file
+</module>
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
new file mode 100644
index 0000000..e92696e
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslator.java
@@ -0,0 +1,9 @@
+package org.rhq.core.domain.util;
+
+/**
+ * GWT friendly impl of this beast.
+ *
+ * @author Lukas Krejci
+ */
+public class JoinFetchReportingQueryTranslator {
+}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java
new file mode 100644
index 0000000..9bd8512
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/core/domain/util/JoinFetchReportingQueryTranslatorFactory.java
@@ -0,0 +1,7 @@
+package org.rhq.core.domain.util;
+
+/**
+ * @author Lukas Krejci
+ */
+public class JoinFetchReportingQueryTranslatorFactory {
+}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 8f0d2cc..d7cc470 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -308,7 +308,11 @@ public final class CriteriaQueryGenerator {
public String getQueryString(boolean countQuery) {
StringBuilder results = new StringBuilder();
+
+ PageControl pc = getPageControl(criteria);
+
results.append("SELECT ");
+
if (countQuery) {
if (groupByClause == null) { // non-grouped method
// use count(*) instead of count(alias) due to https://bugzilla.redhat.com/show_bug.cgi?id=699842
@@ -325,7 +329,9 @@ public final class CriteriaQueryGenerator {
results.append(projection).append(NL);
}
}
+
results.append("FROM ").append(className).append(' ').append(alias).append(NL);
+
if (countQuery == false) {
/*
* don't fetch in the count query to avoid: "query specified join fetching,
@@ -336,19 +342,28 @@ public final class CriteriaQueryGenerator {
addPersistentBag(fetchField);
} else {
if (this.projection == null) {
- /*
+ /*
* if not altering the projection, join fetching can be using
* to retrieve the associated instance in the same SELECT
+ *
+ * We further avoid a JOIN FETCH when executing queries with limits.
+ * Such execution has performance problems that we solve by initializing the fields
+ * "manually" in the CriteriaQueryRunner and by defining a default batch fetch size in the
+ * persistence.xml.
*/
- results.append("LEFT JOIN FETCH ").append(alias).append('.').append(fetchField).append(NL);
+ if (pc.isUnlimited()) {
+ results.append("LEFT JOIN FETCH ").append(alias).append('.').append(fetchField).append(NL);
+ } else {
+ addJoinFetch(fetchField);
+ }
} else {
- /*
+ /*
* if the projection is altered (perhaps converting it into a constructor query), then all
* fields specified in the fetch must be in the explicit return list. this is not possible
* today with constructor queries, so any altered projection will implicitly disable fetching.
* instead, we'll record which fields need to be explicitly fetched after the primary query
* returns the bulk of the data, and use a similar methodology at the SLSB layer to eagerly
- * load those before returning the PageList back to the caller.
+ * load those before returning the PageList back to the caller.
*/
addJoinFetch(fetchField);
}
@@ -357,7 +372,6 @@ public final class CriteriaQueryGenerator {
}
// figure out the 'LEFT JOIN's needed for 'ORDER BY' tokens
- PageControl pc = getPageControl(criteria);
List<String> orderingFieldRequiredJoins = new ArrayList<String>();
List<String> orderingFieldTokens = new ArrayList<String>();
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryRunner.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryRunner.java
index d2a28d5..a788fb0 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryRunner.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryRunner.java
@@ -25,6 +25,7 @@ package org.rhq.enterprise.server.util;
import java.lang.reflect.Field;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
@@ -46,7 +47,7 @@ public class CriteriaQueryRunner<T> {
private Criteria criteria;
private CriteriaQueryGenerator queryGenerator;
private EntityManager entityManager;
- private boolean automaticFetching;;
+ private boolean automaticFetching;
public CriteriaQueryRunner(Criteria criteria, CriteriaQueryGenerator queryGenerator, EntityManager entityManager) {
this(criteria, queryGenerator, entityManager, true);
@@ -61,7 +62,7 @@ public class CriteriaQueryRunner<T> {
}
public PageList<T> execute() {
- PageList<T> results = null;
+ PageList<T> results;
PageControl pageControl = CriteriaQueryGenerator.getPageControl(criteria);
Restriction criteriaRestriction = criteria.getRestriction();
@@ -109,7 +110,7 @@ public class CriteriaQueryRunner<T> {
initPersistentBags(entity);
}
}
- if (queryGenerator.isProjectionAltered() && !queryGenerator.getJoinFetchFields().isEmpty()) {
+ if (!queryGenerator.getJoinFetchFields().isEmpty()) {
for (T entity : results) {
initJoinFetchFields(entity);
}
@@ -148,7 +149,15 @@ public class CriteriaQueryRunner<T> {
private void initialize(Object entity, Field field) {
try {
field.setAccessible(true);
- Hibernate.initialize(field.get(entity));
+
+ Object instance = field.get(entity);
+
+ Hibernate.initialize(instance);
+
+ if (instance instanceof Iterable) {
+ Iterator<?> it = ((Iterable<?>)instance).iterator();
+ while(it.hasNext()) it.next();
+ }
} catch (Exception e) {
LOG.warn("Could not initialize " + field);
}
diff --git a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/safeinvoker/HibernateDetachUtility.java b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/safeinvoker/HibernateDetachUtility.java
index c012d90..8259fde 100644
--- a/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/safeinvoker/HibernateDetachUtility.java
+++ b/modules/enterprise/server/safe-invoker/src/main/java/org/rhq/enterprise/server/safeinvoker/HibernateDetachUtility.java
@@ -419,7 +419,7 @@ public class HibernateDetachUtility {
String assistNameDelimiter = assistClassName.contains("javassist") ? "_$$_" : "$$";
assistClassName = assistClassName.substring(0, assistClassName.indexOf(assistNameDelimiter));
- if (!replacement.getClass().getName().contains("hibernate")) {
+ if (replacement != null && !replacement.getClass().getName().contains("hibernate")) {
nullOutUninitializedFields(replacement, checkedObjects, checkedObjectCollisionMap,
depth + 1, serializationType);
@@ -607,4 +607,4 @@ public class HibernateDetachUtility {
// ignore this
}
}
-}
\ No newline at end of file
+}
commit 6079e06ac677015c8f87838e7ac8e52cc766d5f6
Author: Thomas Segismont <tsegismo(a)redhat.com>
Date: Mon May 13 12:36:17 2013 +0200
Bug 962379 - [as7] Garbage Collector Resource misses 'collection-count' and 'collection-time' per minute metrics
diff --git a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
index 742c4d5..4a26d19 100644
--- a/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/jboss-as-7/src/main/resources/META-INF/rhq-plugin.xml
@@ -7214,8 +7214,8 @@
<c:simple-property name="includeRuntime" readOnly="true" default="true"/>
</plugin-configuration>
- <metric property="collection-count" description="The total number of collections that have occurred."/>
- <metric property="collection-time" description="The approximate accumulated collection elapsed time in milliseconds."/>
+ <metric property="collection-count" description="The total number of collections that have occurred." measurementType="trendsup"/>
+ <metric property="collection-time" description="The approximate accumulated collection elapsed time in milliseconds." measurementType="trendsup"/>
<metric property="name" dataType="trait" description="The name representing this garbage collector"/>
<metric property="valid" dataType="trait" description="Whether this this memory manager is valid in the Java virtual machine."/>
commit 8130e34b50dfc81ae0074ac789d784d159b7b9aa
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri May 10 17:01:01 2013 -0400
BZ 699893 911692 - if the user ran EAP 5 with cmd line option -Djboss.server.data.dir=/some/data/dir
then the AS5 plugin should look there, too, to try to find the jnp-service.url file
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
index 01eb105..670347f 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/ApplicationServerDiscoveryComponent.java
@@ -500,32 +500,42 @@ public class ApplicationServerDiscoveryComponent implements ResourceDiscoveryCom
}
private String getJnpURL(JBossInstanceInfo cmdLine, File installHome, File configDir) {
- File jnpServiceUrlFile = new File(configDir, "data/jnp-service.url");
- if (jnpServiceUrlFile.exists() && jnpServiceUrlFile.canRead()) {
- BufferedReader br = null;
- try {
- br = new BufferedReader(new FileReader(jnpServiceUrlFile));
- String jnpUrl = br.readLine();
- if (jnpUrl != null) {
- if (log.isDebugEnabled()) {
- log.debug("Read JNP URL from jnp-service.url file: " + jnpUrl);
+ ArrayList<File> possibleJnpServiceUrlFiles = new ArrayList<File>(2);
+ possibleJnpServiceUrlFiles.add(new File(configDir, "data/jnp-service.url"));
+ // if the app server was told to go somewhere else to store its data files, look in there too (BZ 699893)
+ if (cmdLine.getSystemProperties() != null) {
+ String dataDir = cmdLine.getSystemProperties().getProperty("jboss.server.data.dir");
+ if (dataDir != null) {
+ possibleJnpServiceUrlFiles.add(new File(dataDir, "jnp-service.url"));
+ }
+ }
+ for (File jnpServiceUrlFile : possibleJnpServiceUrlFiles) {
+ if (jnpServiceUrlFile.exists() && jnpServiceUrlFile.canRead()) {
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(jnpServiceUrlFile));
+ String jnpUrl = br.readLine();
+ if (jnpUrl != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("Read JNP URL from jnp-service.url file: " + jnpUrl);
+ }
+ return jnpUrl;
}
- return jnpUrl;
- }
- } catch (IOException ioe) {
- // Nothing to do
- } finally {
- if (br != null) {
- try {
- br.close();
- } catch (IOException e) {
- // nada
+ } catch (IOException ioe) {
+ // Nothing to do
+ } finally {
+ if (br != null) {
+ try {
+ br.close();
+ } catch (IOException e) {
+ // nada
+ }
}
}
}
}
- log.warn("Failed to read JNP URL from '" + jnpServiceUrlFile + "'.");
+ log.warn("Failed to read JNP URL from: " + possibleJnpServiceUrlFiles);
// Above did not work, so fall back to our previous scheme
JnpConfig jnpConfig = getJnpConfig(installHome, configDir, cmdLine.getSystemProperties());
commit d2523a093115225352825051b5a795a7226a7c23
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri May 10 15:56:04 2013 -0400
BZ 903402 - fix code if windows drive is missing but otherwise the path is absolute
diff --git a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java
index 35a2263..e3c4a27 100644
--- a/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java
+++ b/modules/plugins/jboss-as-5/src/main/java/org/rhq/plugins/jbossas5/helper/JBossInstanceInfo.java
@@ -243,7 +243,7 @@ public class JBossInstanceInfo {
for (String pathElement : this.classPath) {
if (pathElement.endsWith("run.jar")) {
runJar = new File(pathElement);
- if (!runJar.isAbsolute()) {
+ if (!runJar.isAbsolute() && !runJar.exists()) {
runJar = new File(this.processInfo.getExecutable().getCwd(), runJar.getPath());
}
if (!runJar.exists()) {
diff --git a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java
index 9dadd39..b515af7 100644
--- a/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java
+++ b/modules/plugins/jboss-as/src/main/java/org/rhq/plugins/jbossas/helper/JBossInstanceInfo.java
@@ -237,7 +237,7 @@ public class JBossInstanceInfo {
for (String pathElement : this.classPath) {
if (pathElement.endsWith("run.jar")) {
runJar = new File(pathElement);
- if (!runJar.isAbsolute()) {
+ if (!runJar.isAbsolute() && !runJar.exists()) {
runJar = new File(this.processInfo.getExecutable().getCwd(), runJar.getPath());
}
if (!runJar.exists()) {
11 years
[rhq] 2 commits - modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java | 6 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java | 9 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 51 ++++++----
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java | 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java | 18 ++-
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties | 1
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties | 1
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java | 27 +++--
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java | 23 ++++
16 files changed, 108 insertions(+), 39 deletions(-)
New commits:
commit 3ef61c1860a590b16b461b81f85b0011b2ee620d
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon May 20 13:36:45 2013 +0200
[BZ 958169] - Modified alert definition is not saved on confirming the save message after clicking on 'Back to List' button - New method for creating an alert definitions was added to SLSB, because the UI requires the ids of newly created alert conditions.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
index b90b209..8fe6d4b 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionEditor.java
@@ -140,7 +140,7 @@ public class ConditionEditor extends EnhancedVLayout {
private AlertCondition existingCondition;
public ConditionEditor(HashSet<AlertCondition> conditions, Map<Integer, AlertCondition> modifiedConditions,
- SelectItem conditionExpression, ResourceType rtype, Runnable closeFunc, AlertCondition existingCondition) {
+ SelectItem conditionExpression, ResourceType rtype, AlertCondition existingCondition, Runnable closeFunc) {
super();
this.editMode = existingCondition != null;
this.existingCondition = existingCondition;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
index 782e4b5..8f4a36f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ConditionsEditor.java
@@ -196,7 +196,7 @@ public class ConditionsEditor extends EnhancedVLayout {
}
});
- table.addTableAction(MSG.common_button_edit(), null, new AbstractTableAction(TableActionEnablement.SINGLE) {
+ table.addTableAction(MSG.view_alert_definition_editCondition(), null, new AbstractTableAction(TableActionEnablement.SINGLE) {
public void executeAction(ListGridRecord[] selection, Object actionValue) {
AlertCondition condition = getDataSource().copyValues(selection[0]);
showConditionEditor(condition);
@@ -252,7 +252,7 @@ public class ConditionsEditor extends EnhancedVLayout {
final int numConditions = conditions.size();
final ConditionEditor newConditionEditor = new ConditionEditor(conditions, modifiedConditions,
ConditionsEditor.this.conditionExpression, ConditionsEditor.this.resourceType,
- new Runnable() {
+ existingCondition, new Runnable() {
@Override
public void run() {
updated = updated || numConditions != conditions.size()
@@ -260,7 +260,7 @@ public class ConditionsEditor extends EnhancedVLayout {
winModal.markForDestroy();
refresh();
}
- }, existingCondition);
+ });
winModal.addItem(newConditionEditor);
winModal.show();
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
index 2cbe8c6..d69f7f4 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/ResourceAlertDefinitionsView.java
@@ -197,15 +197,14 @@ public class ResourceAlertDefinitionsView extends AbstractAlertDefinitionsView {
protected void commitAlertDefinition(final AlertDefinition alertDefinition, boolean purgeInternals,
final AsyncCallback<AlertDefinition> resultReceiver) {
if (alertDefinition.getId() == 0) {
- GWTServiceLookup.getAlertDefinitionService().createAlertDefinition(alertDefinition,
- Integer.valueOf(resource.getId()), new AsyncCallback<Integer>() {
+ GWTServiceLookup.getAlertDefinitionService().createAlertDefinitionAndReturn(alertDefinition,
+ Integer.valueOf(resource.getId()), new AsyncCallback<AlertDefinition>() {
@Override
- public void onSuccess(Integer result) {
+ public void onSuccess(AlertDefinition result) {
CoreGUI.getMessageCenter().notify(
new Message(MSG.view_alert_definitions_create_success(), Severity.Info));
- alertDefinition.setId(result.intValue());
ResourceAlertDefinitionsView.this.refresh();
- resultReceiver.onSuccess(alertDefinition);
+ resultReceiver.onSuccess(result);
}
@Override
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index c86d0cd..25742f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -146,10 +146,7 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
- // enable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
+ unregisterHandler();
setAlertDefinition(getAlertDefinition()); // reverts data back to original
makeViewOnly();
}
@@ -159,6 +156,15 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
addMember(tabSet);
addMember(buttons);
}
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+ if (alertDefinition == null || alertDefinition.getId() == 0) {
+ // disable the back button when creating new definition
+ setBackButtonDisabled(true);
+ }
+ }
public AlertDefinition getAlertDefinition() {
return alertDefinition;
@@ -197,8 +203,7 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
recovery.makeEditable();
dampening.makeEditable();
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
+ unregisterHandler();
handlerRegistration = addVisibilityChangedHandler(new VisibilityChangedHandler() {
public void onVisibilityChanged(VisibilityChangedEvent event) {
if (!event.getIsVisible()) {
@@ -207,15 +212,13 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
if (value) {
save();
}
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
}
});
}
}
});
// disable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(true);
+ setBackButtonDisabled(true);
}
public void makeViewOnly() {
@@ -228,6 +231,7 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
notifications.makeViewOnly();
recovery.makeViewOnly();
dampening.makeViewOnly();
+ setBackButtonDisabled(false);
}
public void saveAlertDefinition() {
@@ -249,20 +253,13 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(final AlertDefinition alertDef) {
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
setAlertDefinition(alertDef);
- // enable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
+ unregisterHandler();
}
@Override
public void onFailure(Throwable caught) {
- if (handlerRegistration != null)
- handlerRegistration.removeHandler();
- // enable the back button
- ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
-
+ unregisterHandler();
// no error handling, the notification is done in the subclasses of AbstractAlertDefinitionsView
}
});
@@ -270,4 +267,22 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
tabSet.selectTab(generalPropertiesTab);
}
}
+
+ private void setBackButtonDisabled(boolean enabled) {
+ Canvas layoutCandidate = getParentElement();
+ if (layoutCandidate instanceof EnhancedVLayout) {
+ EnhancedVLayout parentLayout = (EnhancedVLayout) getParentElement();
+ Canvas backButton = parentLayout.getMember("backButton");
+ if (backButton != null) {
+ backButton.setDisabled(enabled);
+ }
+ }
+ }
+
+ private void unregisterHandler() {
+ if (handlerRegistration != null) {
+ handlerRegistration.removeHandler();
+ handlerRegistration = null;
+ }
+ }
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
index 0921b2b..794a67f 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/gwt/AlertDefinitionGWTService.java
@@ -32,6 +32,9 @@ public interface AlertDefinitionGWTService extends RemoteService {
int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException;
+ AlertDefinition createAlertDefinitionAndReturn(AlertDefinition alertDefinition, Integer resourceId)
+ throws RuntimeException;
+
AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition, boolean purgeInternals)
throws RuntimeException;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
index 181eef5..da1d981 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/server/gwt/AlertDefinitionGWTServiceImpl.java
@@ -66,8 +66,18 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
@Override
public int createAlertDefinition(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException {
try {
- int results = alertDefManager.createAlertDefinitionInNewTransaction(getSessionSubject(), alertDefinition, resourceId, true);
- return results;
+ int result = alertDefManager.createAlertDefinitionInNewTransaction(getSessionSubject(), alertDefinition, resourceId, true);
+ return result;
+ } catch (Throwable t) {
+ throw getExceptionToThrowToClient(t);
+ }
+ }
+
+ @Override
+ public AlertDefinition createAlertDefinitionAndReturn(AlertDefinition alertDefinition, Integer resourceId) throws RuntimeException {
+ try {
+ AlertDefinition result = alertDefManager.createAlertDefinitionAndRerurnIt(getSessionSubject(), alertDefinition, resourceId, true);
+ return SerialUtility.prepare(result, "createAlertDefinitionAndReturn");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
@@ -77,9 +87,9 @@ public class AlertDefinitionGWTServiceImpl extends AbstractGWTServiceImpl implem
public AlertDefinition updateAlertDefinition(int alertDefinitionId, AlertDefinition alertDefinition,
boolean resetMatching) throws RuntimeException {
try {
- AlertDefinition results = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId,
+ AlertDefinition result = alertDefManager.updateAlertDefinition(getSessionSubject(), alertDefinitionId,
alertDefinition, resetMatching);
- return SerialUtility.prepare(results, "updateAlertDefinition");
+ return SerialUtility.prepare(result, "updateAlertDefinition");
} catch (Throwable t) {
throw getExceptionToThrowToClient(t);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
index d00a969..8f8fec5 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerBean.java
@@ -201,19 +201,30 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public int createDependentAlertDefinition(Subject subject, AlertDefinition alertDefinition, int resourceId)
throws InvalidAlertDefinitionException {
-
- return createAlertDefinitionInternal(subject, alertDefinition, resourceId, false, false);
+ AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, false,
+ false);
+ return newAlertDefinition.getId();
}
@Override
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
- public int createAlertDefinitionInNewTransaction(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean validateNotificationConfiguration)
- throws InvalidAlertDefinitionException {
-
- return createAlertDefinitionInternal(subject, alertDefinition, resourceId, true, validateNotificationConfiguration);
+ public int createAlertDefinitionInNewTransaction(Subject subject, AlertDefinition alertDefinition,
+ Integer resourceId, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
+ AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, true,
+ validateNotificationConfiguration);
+ return newAlertDefinition.getId();
+ }
+
+ @Override
+ @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
+ public AlertDefinition createAlertDefinitionAndRerurnIt(Subject subject, AlertDefinition alertDefinition,
+ Integer resourceId, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
+ AlertDefinition newAlertDefinition = createAlertDefinitionInternal(subject, alertDefinition, resourceId, true,
+ validateNotificationConfiguration);
+ return newAlertDefinition;
}
- private int createAlertDefinitionInternal(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean checkPerms, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
+ private AlertDefinition createAlertDefinitionInternal(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean checkPerms, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException {
checkAlertDefinition(subject, null, alertDefinition, resourceId, validateNotificationConfiguration);
// if this is an resource alert definition, set up the link to a resource
@@ -279,7 +290,7 @@ public class AlertDefinitionManagerBean implements AlertDefinitionManagerLocal,
AlertDefinitionEvent.CREATED);
}
- return alertDefinition.getId();
+ return alertDefinition;
}
private void fixRecoveryId(AlertDefinition definition) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
index 5afa1f9..ee0e161 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/alert/AlertDefinitionManagerLocal.java
@@ -65,6 +65,29 @@ public interface AlertDefinitionManagerLocal {
*/
int createAlertDefinitionInNewTransaction(Subject subject, AlertDefinition alertDefinition, Integer resourceId, boolean finalizeNotificationConfiguration)
throws InvalidAlertDefinitionException;
+
+ /**
+ * Creates a new alert definition. Note that the suject is checked to have necessary authz, which might not
+ * be what you want in all use cases. See {@link #createDependentAlertDefinition(Subject, AlertDefinition, int)}
+ * for further discussion of this. The only difference between
+ * {@link GroupAlertDefinitionManagerLocal#createAlertDefinitionInNewTransaction(Subject, AlertDefinition, Integer, boolean)}
+ * and this method is the return type.
+ *
+ * @param subject the user creating the alert definition
+ * @param alertDefinition the new alert definition to persist
+ * @param resourceId the resource id for which the def is being created
+ * @param finalizeNotificationConfiguration if true, the configuration of the def's notifications is validated.
+ * This is NOT what you want if, for example, you are merely creating a copy of an existing definition.
+ * Some notifications might require more input when creating the notification than is then persisted in their configs
+ * (prominent example being the CLI alert sender).
+ * This would then cause the validation to fail every time you created a copy of a definition and tried
+ * to persist it. Note that passing false AND having new, unpersisted notifications in the alert definition can
+ * lead to invalid configuration being stored for the notifications.
+ * @return the instance of newly created alert definition
+ * @throws InvalidAlertDefinitionException
+ */
+ AlertDefinition createAlertDefinitionAndRerurnIt(Subject subject, AlertDefinition alertDefinition,
+ Integer resourceId, boolean validateNotificationConfiguration) throws InvalidAlertDefinitionException;
/**
* This is exactly the same as {@link #createAlertDefinitionInNewTransaction(Subject, AlertDefinition, Integer, boolean)} but
commit b638cc12a5796b7ccb3789bf94768303b0ce0e3c
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Mon May 20 13:29:43 2013 +0200
[BZ 958169] - Modified alert definition is not saved on confirming the save message after clicking on 'Back to List' button - I18n (Instead of "Edit", now the button label says "Edit Condition").
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 00a68ef..b630706 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -977,6 +977,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Trait Value
view_alert_definition_condition_editor_option_operation = Operation Execution
view_alert_definition_condition_editor_option_resource_configuration = Resource Configuration Change
view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = View Group Definition
view_alert_definition_for_type = View Template
view_alert_definition_notification_cliScript_editor_anotherUser = Another User
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index a27fb3c..cab205f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -993,6 +993,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Změna hodno
view_alert_definition_condition_editor_option_operation = Spuštění operace
view_alert_definition_condition_editor_option_resource_configuration = Změna konfigurace zdroje
view_alert_definition_condition_editor_resource_configuration_tooltip = Podmínka je splněna, když se změní konfigurace zdroje.
+view_alert_definition_editCondition = Editovat podmínku
view_alert_definition_for_group = Zobrazit definici skupiny
view_alert_definition_for_type = Zobrazit šablonu
view_alert_definition_notification_cliScript_editor_anotherUser = Jiný uživatel
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 902951d..057785a 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -883,6 +883,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Änderung de
view_alert_definition_condition_editor_option_operation = Ausführung der Operation
view_alert_definition_condition_editor_option_resource_configuration = Änderung der Konfiguration der Ressource
##view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = Gruppendefinition ansehen
view_alert_definition_for_type = Vorlage ansehen
view_alert_definition_notification_cliScript_editor_anotherUser = Anderer Benutzer
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 8f47413..a929966 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -969,6 +969,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = トレイト
view_alert_definition_condition_editor_option_operation = オペレーションの実行
view_alert_definition_condition_editor_option_resource_configuration = リソース構成の変化
view_alert_definition_condition_editor_resource_configuration_tooltip = この条件はリソース構成が変更されると引き起こされます
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = ビューグループ定義
view_alert_definition_for_type = ビューテンプレート
view_alert_definition_notification_cliScript_editor_anotherUser = 別のユーザー
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index 5d19d06..da0a8a5 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -846,6 +846,7 @@ view_alert_definition_condition_editor_option_metric_threshold = 측정 절대
view_alert_definition_condition_editor_option_metric_trait_change = 특성값의 변화
view_alert_definition_condition_editor_option_resource_configuration = 자원 구성의 변화
view_alert_definition_condition_editor_resource_configuration_tooltip = 이 조건은 자원 구성이 변경되면 발생합니다.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = 뷰 그룹 정의
view_alert_definition_notification_cliScript_editor_anotherUser = 다른 사용자
view_alert_definition_notification_cliScript_editor_existingScript = 기존의 스크립트
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index 743c4b5..9f342d7 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -977,6 +977,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Mudan\u00E7a
view_alert_definition_condition_editor_option_operation = Execu\u00E7\u00E3o de Opera\u00E7\u00E3o
view_alert_definition_condition_editor_option_resource_configuration = Mudan\u00E7a na Configura\u00E7\u00E3o do Recurso
view_alert_definition_condition_editor_resource_configuration_tooltip = Essa condi\u00E7\u00E3o \u00E9 disparada quando a configura\u00E7\u00E3o do recurso for alterada.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = Visualizar Defini\u00E7\u00E3o de Grupo
view_alert_definition_for_type = Visualizar Template
view_alert_definition_notification_cliScript_editor_anotherUser = Another User
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index 772c4e4..c8ee796 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -943,6 +943,7 @@
#view_alert_definition_condition_editor_option_operation = Operation Execution
#view_alert_definition_condition_editor_option_resource_configuration = Resource Configuration Change
#view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+##view_alert_definition_editCondition = Edit Condition
#view_alert_definition_for_group = View Group Definition
#view_alert_definition_for_type = View Template
#view_alert_definition_notification_cliScript_editor_anotherUser = Another User
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 03dfa4e..147b9f8 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -963,6 +963,7 @@ view_alert_definition_condition_editor_option_metric_trait_change = Trait Value
view_alert_definition_condition_editor_option_operation = Operation Execution
view_alert_definition_condition_editor_option_resource_configuration = \u8d44\u6e90\u914d\u7f6e\u6539\u53d8
view_alert_definition_condition_editor_resource_configuration_tooltip = This condition is triggered when the resource configuration changes.
+##view_alert_definition_editCondition = Edit Condition
view_alert_definition_for_group = \u67e5\u770b\u7ec4\u5b9a\u4e49
view_alert_definition_for_type = \u67e5\u770b\u6a21\u677f
view_alert_definition_notification_cliScript_editor_anotherUser = \u5176\u4ed6\u7528\u6237
11 years
[rhq] Branch 'feature/cassandra-backend' - modules/common
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 828a99ea00bee43668cbcb161682372f4ab3b1f2
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat May 18 16:59:25 2013 -0400
fix setter method for startRpc deployment property
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java
index e10d180..33e4e25 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/DeploymentOptions.java
@@ -366,7 +366,7 @@ public class DeploymentOptions {
* @param startRpc whether the Thrift-based RPC should be started
*/
public void setStartRpc(Boolean startRpc) {
- if (startRpc == null) {
+ if (this.startRpc == null) {
this.startRpc = startRpc;
}
}
11 years
[rhq] Branch 'feature/cassandra-backend' - 3 commits - modules/common modules/enterprise modules/helpers
by John Sanda
modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml | 2
modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MetricsManagerBean.java | 2
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java | 12 -
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java | 72 ++++++----
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java | 10 -
modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java | 53 +++----
modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/MeasurementAggregator.java | 2
8 files changed, 93 insertions(+), 62 deletions(-)
New commits:
commit ea7e1bdcf5684f3b32353a0ceb0fa01e1b0c8faa
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat May 18 14:12:22 2013 -0400
need to pass timestamp to calculateAggregates now
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MetricsManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MetricsManagerBean.java
index 5e30683..26d580b 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MetricsManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MetricsManagerBean.java
@@ -60,7 +60,7 @@ public class MetricsManagerBean implements MetricsManagerLocal {
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
public Iterable<AggregateNumericMetric> calculateAggregates() {
MetricsServer metricsServer = getMetricsServer();
- return metricsServer.calculateAggregates();
+ return metricsServer.calculateAggregates(System.currentTimeMillis());
}
@Override
commit 24b2ca97916cfa9b2a87ac80ceee30ecec121887
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat May 18 13:56:58 2013 -0400
updating schema for metrics_index table so that rows are not reused
The way in which the metrics_index table has been used followed a big C*
anti-pattern. There was was one row devoted for each bucket that has data to be
aggregated. Once all of the schedules in a given row had their data aggregated
all of the columns in the row were deleted. This is increasingly inefficient as
the data set grows for a couple reasons. First, reads become slower because C*
has to iterate over more and more tombstone columns. Secondly, those tombstone
columns use up memory just like live columns do.
The columns stored are the same, but we are now using a compound row/partition
key that consists of the bucket name and a timestamp. The timestamp is the
start of an interval for a given bucket. So let's say we store some raw data at
12:22 pm. We will then update the {'one_hour_metrics', 12:00} row in the
metrics_index table for that schedule id. After 13:00, that will will never be
written to again and when aggregation runs over that time interval, the entire
row will be deleted. This way, reads against the metrics_index table will
always be over live columns and not tombstones.
diff --git a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
index 068e90f..0eec414 100644
--- a/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
+++ b/modules/common/cassandra-schema/src/main/java/org/rhq/cassandra/schema/SchemaManager.java
@@ -217,7 +217,7 @@ public class SchemaManager {
"bucket varchar, " +
"time timestamp, " +
"schedule_id int, " +
- "PRIMARY KEY (bucket, time, schedule_id) " +
+ "PRIMARY KEY ((bucket, time), schedule_id) " +
") WITH COMPACT STORAGE;"
);
} catch (NoHostAvailableException e) {
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java
index 03ee04c..dd5c44c 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsDAO.java
@@ -136,9 +136,9 @@ public class MetricsDAO {
MetricsTable.TWENTY_FOUR_HOUR + " WHERE schedule_id = ? AND time >= ? AND time < ?");
findIndexEntries = session.prepare("SELECT time, schedule_id FROM " + MetricsTable.INDEX +
- " WHERE bucket = ? ORDER BY time");
+ " WHERE bucket = ? AND time = ?");
- deleteIndexEntries = session.prepare("DELETE FROM " + MetricsTable.INDEX + " WHERE bucket = ?");
+ deleteIndexEntries = session.prepare("DELETE FROM " + MetricsTable.INDEX + " WHERE bucket = ? AND time = ?");
}
public ResultSet insertRawData(MeasurementDataNumeric data) {
@@ -288,8 +288,8 @@ public class MetricsDAO {
new AggregateNumericMetricMapper(), session);
}
- public Iterable<MetricsIndexEntry> findMetricsIndexEntries(final MetricsTable table) {
- BoundStatement statement = findIndexEntries.bind(table.toString());
+ public Iterable<MetricsIndexEntry> findMetricsIndexEntries(final MetricsTable table, long timestamp) {
+ BoundStatement statement = findIndexEntries.bind(table.toString(), new Date(timestamp));
return new SimplePagedResult<MetricsIndexEntry>(statement, new MetricsIndexEntryMapper(table), session);
}
@@ -301,8 +301,8 @@ public class MetricsDAO {
}
}
- public void deleteMetricsIndexEntries(MetricsTable table) {
- BoundStatement statement = deleteIndexEntries.bind(table.getTableName());
+ public void deleteMetricsIndexEntries(MetricsTable table, long timestamp) {
+ BoundStatement statement = deleteIndexEntries.bind(table.getTableName(), new Date(timestamp));
session.execute(statement);
}
}
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
index 10421d6..fd285ee 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/MetricsServer.java
@@ -26,6 +26,8 @@
package org.rhq.server.metrics;
import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -67,7 +69,6 @@ public class MetricsServer {
public void setSession(Session session) {
this.session = session;
- //dao = new MetricsDAO(session);
}
public void setDAO(MetricsDAO dao) {
@@ -250,47 +251,74 @@ public class MetricsServer {
updates.put(rawMetric.getScheduleId(), dateTimeService.getTimeSlice(
new DateTime(rawMetric.getTimestamp()), configuration.getRawTimeSliceDuration()).getMillis());
}
+ Set<Date> dates = new HashSet<Date>();
+ for (Long ts : updates.values()) {
+ dates.add(new Date(ts));
+ }
+ log.info("Updating one hour index wtih time slices " + dates);
dao.updateMetricsIndex(MetricsTable.ONE_HOUR, updates);
}
- public Iterable<AggregateNumericMetric> calculateAggregates() {
+ /**
+ * Computes and stores aggregate for all time slices that are ready to be aggregated.
+ * This is includes raw, 1hr, 6hr, and 24hr data.
+ *
+ * @param startTime A timestamp that the determines the period over which data will be
+ * aggregated. Aggregation is normally run hourly as part of the data
+ * purge job; so, this timestamp is rounded down to the hour and then
+ * an hour is subtracted to get the actual starting time over which
+ * data will be aggregated. Suppose the argument has a value (time) of
+ * 02:00:34. This means that raw data that has been stored between
+ * 01:00 and 02:00 will be aggregated.
+ *
+ * @return One hour aggregates. That is, any raw data that has been rolled up into onr
+ * one hour aggregates. The one hour aggregates are returned because they are needed
+ * for subsequently computing baselines.
+ */
+ public Iterable<AggregateNumericMetric> calculateAggregates(long startTime) {
+ DateTime dt = new DateTime(startTime);
+ DateTime currentHour = dateTimeService.getTimeSlice(dt, configuration.getRawTimeSliceDuration());
+ DateTime lastHour = currentHour.minusHours(1);
+
+ long hourTimeSlice = lastHour.getMillis();
+
+ long sixHourTimeSlice = dateTimeService.getTimeSlice(lastHour,
+ configuration.getOneHourTimeSliceDuration()).getMillis();
+
+ long twentyFourHourTimeSlice = dateTimeService.getTimeSlice(lastHour,
+ configuration.getSixHourTimeSliceDuration()).getMillis();
+
// We first query the metrics index table to determine which schedules have data to
// be aggregated. Then we retrieve the metric data and aggregate or compress the
// data, writing the compressed values into the next wider (i.e., longer life span
// for data) bucket/table. At this point we remove the index entries for the data
- // that has already been processed. We currently purge the entire row in the index
- // table. We can safely do this entire work flow is single threaded. It might make
- // sense to perform the deletes in a more granular fashion to avoid concurrency
- // issues in the future. The last step in the work flow is to update the metrics
+ // that has already been processed. We purge the entire row in the index table.
+ // We can safely do this because the row wi..
+ //
+ // The last step in the work flow is to update the metrics
// index for the newly persisted aggregates.
- // TODO deleteMetricsIndexEntries should take a list of schedule ids
- // MetricsDAO.deleteMetricsIndexEntries deletes the entire row, but we probably do
- // not want to delete each column unless and until we verify that the data for the
- // schedule id in that column has in fact been aggregated. It might be better for
- // deleteMetricsIndexEntries to take a list of schedule ids to purge.
-
Iterable<AggregateNumericMetric> newOneHourAggregates = null;
- List<AggregateNumericMetric> updatedSchedules = aggregateRawData();
+ List<AggregateNumericMetric> updatedSchedules = aggregateRawData(hourTimeSlice);
newOneHourAggregates = updatedSchedules;
if (!updatedSchedules.isEmpty()) {
- dao.deleteMetricsIndexEntries(MetricsTable.ONE_HOUR);
+ dao.deleteMetricsIndexEntries(MetricsTable.ONE_HOUR, hourTimeSlice);
updateMetricsIndex(MetricsTable.SIX_HOUR, updatedSchedules, configuration.getOneHourTimeSliceDuration());
}
- updatedSchedules = calculateAggregates(MetricsTable.ONE_HOUR, MetricsTable.SIX_HOUR,
+ updatedSchedules = calculateAggregates(MetricsTable.ONE_HOUR, MetricsTable.SIX_HOUR, sixHourTimeSlice,
configuration.getOneHourTimeSliceDuration());
if (!updatedSchedules.isEmpty()) {
- dao.deleteMetricsIndexEntries(MetricsTable.SIX_HOUR);
+ dao.deleteMetricsIndexEntries(MetricsTable.SIX_HOUR, sixHourTimeSlice);
updateMetricsIndex(MetricsTable.TWENTY_FOUR_HOUR, updatedSchedules,
configuration.getSixHourTimeSliceDuration());
}
updatedSchedules = calculateAggregates(MetricsTable.SIX_HOUR, MetricsTable.TWENTY_FOUR_HOUR,
- configuration.getSixHourTimeSliceDuration());
+ twentyFourHourTimeSlice, configuration.getSixHourTimeSliceDuration());
if (!updatedSchedules.isEmpty()) {
- dao.deleteMetricsIndexEntries(MetricsTable.TWENTY_FOUR_HOUR);
+ dao.deleteMetricsIndexEntries(MetricsTable.TWENTY_FOUR_HOUR, twentyFourHourTimeSlice);
}
return newOneHourAggregates;
@@ -305,8 +333,8 @@ public class MetricsServer {
dao.updateMetricsIndex(bucket, updates);
}
- private List<AggregateNumericMetric> aggregateRawData() {
- Iterable<MetricsIndexEntry> indexEntries = dao.findMetricsIndexEntries(MetricsTable.ONE_HOUR);
+ private List<AggregateNumericMetric> aggregateRawData(long theHour) {
+ Iterable<MetricsIndexEntry> indexEntries = dao.findMetricsIndexEntries(MetricsTable.ONE_HOUR, theHour);
List<AggregateNumericMetric> oneHourMetrics = new ArrayList<AggregateNumericMetric>();
for (MetricsIndexEntry indexEntry : indexEntries) {
@@ -356,9 +384,9 @@ public class MetricsServer {
}
private List<AggregateNumericMetric> calculateAggregates(MetricsTable fromTable,
- MetricsTable toTable, Duration nextDuration) {
+ MetricsTable toTable, long timeSlice, Duration nextDuration) {
- Iterable<MetricsIndexEntry> indexEntries = dao.findMetricsIndexEntries(toTable);
+ Iterable<MetricsIndexEntry> indexEntries = dao.findMetricsIndexEntries(toTable, timeSlice);
List<AggregateNumericMetric> toMetrics = new ArrayList<AggregateNumericMetric>();
DateTime currentHour = getCurrentHour();
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
index 261cd13..8f35486 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsDAOTest.java
@@ -271,7 +271,8 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
updates.put(scheduleId2, hour0.getMillis());
dao.updateMetricsIndex(MetricsTable.ONE_HOUR, updates);
- List<MetricsIndexEntry> actual = Lists.newArrayList(dao.findMetricsIndexEntries(MetricsTable.ONE_HOUR));
+ List<MetricsIndexEntry> actual = Lists.newArrayList(dao.findMetricsIndexEntries(MetricsTable.ONE_HOUR,
+ hour0.getMillis()));
List<MetricsIndexEntry> expected = asList(new MetricsIndexEntry(MetricsTable.ONE_HOUR, hour0, scheduleId1),
new MetricsIndexEntry(MetricsTable.ONE_HOUR, hour0, scheduleId2));
@@ -285,13 +286,12 @@ public class MetricsDAOTest extends CassandraIntegrationTest {
Map<Integer, Long> updates = new HashMap<Integer, Long>();
updates.put(scheduleId1, hour0().getMillis());
updates.put(scheduleId2, hour0().getMillis());
- updates.put(scheduleId1, hour0().plusHours(1).getMillis());
- updates.put(scheduleId2, hour0().plusHours(1).getMillis());
dao.updateMetricsIndex(MetricsTable.ONE_HOUR, updates);
- dao.deleteMetricsIndexEntries(MetricsTable.ONE_HOUR);
+ dao.deleteMetricsIndexEntries(MetricsTable.ONE_HOUR, hour0().getMillis());
- List<MetricsIndexEntry> index = Lists.newArrayList(dao.findMetricsIndexEntries(MetricsTable.ONE_HOUR));
+ List<MetricsIndexEntry> index = Lists.newArrayList(dao.findMetricsIndexEntries(MetricsTable.ONE_HOUR,
+ hour0().getMillis()));
assertEquals(index.size(), 0, "Expected index for " + MetricsTable.ONE_HOUR + " to be empty but found " +
index);
}
diff --git a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java
index 7ac617f..d895753 100644
--- a/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java
+++ b/modules/enterprise/server/server-metrics/src/test/java/org/rhq/server/metrics/MetricsServerTest.java
@@ -152,10 +152,12 @@ public class MetricsServerTest extends CassandraIntegrationTest {
assertColumnMetadataEquals(scheduleId, hour0.plusHours(4), hour0.plusHours(5), MetricsTable.RAW.getTTL(),
timestamp);
- List<MetricsIndexEntry> expectedIndex = asList(new MetricsIndexEntry(MetricsTable.ONE_HOUR,
- hour0.plusHours(4), scheduleId));
- assertMetricsIndexEquals(MetricsTable.ONE_HOUR, expectedIndex, "Failed to update index for "
- + MetricsTable.ONE_HOUR);
+ DateTime hour4 = hour0.plusHours(4);
+
+ List<MetricsIndexEntry> expectedIndex = asList(new MetricsIndexEntry(MetricsTable.ONE_HOUR, hour4,
+ scheduleId));
+ assertMetricsIndexEquals(MetricsTable.ONE_HOUR, hour4.getMillis(), expectedIndex,
+ "Failed to update index for " + MetricsTable.ONE_HOUR);
}
@Test//(enabled = ENABLED)
@@ -176,7 +178,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
metricsServer.setCurrentHour(hour6);
metricsServer.addNumericData(data);
- metricsServer.calculateAggregates();
+ metricsServer.calculateAggregates(hour6.getMillis());
// verify that one hour metric data is updated
List<AggregateNumericMetric> expected = asList(new AggregateNumericMetric(scheduleId,
@@ -218,7 +220,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
metricsServer.updateMetricsIndex(rawMetrics);
metricsServer.setCurrentHour(hour9);
- metricsServer.calculateAggregates();
+ metricsServer.calculateAggregates(hour9.getMillis());
// verify that the 1 hour aggregates are calculated
assert1HourDataEquals(scheduleId, asList(new AggregateNumericMetric(scheduleId, divide((1.1 + 2.2 + 3.3), 3),
@@ -228,8 +230,8 @@ public class MetricsServerTest extends CassandraIntegrationTest {
List<MetricsIndexEntry> expected6HourIndex = asList(new MetricsIndexEntry(MetricsTable.SIX_HOUR,
dateTimeService.getTimeSlice(hour9, Minutes.minutes(60 * 6)), scheduleId));
- assertMetricsIndexEquals(MetricsTable.SIX_HOUR, expected6HourIndex, "Failed to update index for "
- + MetricsTable.SIX_HOUR);
+ assertMetricsIndexEquals(MetricsTable.SIX_HOUR, hour9.minusHours(3).getMillis(), expected6HourIndex,
+ "Failed to update index for " + MetricsTable.SIX_HOUR);
// The 6 hour data should not get aggregated since the current 6 hour time slice
// has not passed yet. More specifically, the aggregation job is running at 09:00
@@ -237,10 +239,10 @@ public class MetricsServerTest extends CassandraIntegrationTest {
assert6HourDataEmpty(scheduleId);
// verify that the 24 hour index is empty
- assert24HourMetricsIndexEmpty(scheduleId);
+ assert24HourMetricsIndexEmpty(scheduleId, hour0.getMillis());
// verify that the 1 hour queue has been purged
- assert1HourMetricsIndexEmpty(scheduleId);
+ assert1HourMetricsIndexEmpty(scheduleId, hour9.getMillis());
}
@Test//(enabled = ENABLED)
@@ -280,7 +282,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
// execute the system under test
metricsServer.setCurrentHour(hour12);
- metricsServer.calculateAggregates();
+ metricsServer.calculateAggregates(hour12.getMillis());
// verify the results
// verify that the one hour data has been aggregated
@@ -288,10 +290,10 @@ public class MetricsServerTest extends CassandraIntegrationTest {
max1, hour6.getMillis())));
// verify that the 6 hour queue has been updated
- assert6HourMetricsIndexEmpty(scheduleId);
+ assert6HourMetricsIndexEmpty(scheduleId, hour6.getMillis());
// verify that the 24 hour queue is updated
- assertMetricsIndexEquals(MetricsTable.TWENTY_FOUR_HOUR, asList(new MetricsIndexEntry(
+ assertMetricsIndexEquals(MetricsTable.TWENTY_FOUR_HOUR, hour0.getMillis(), asList(new MetricsIndexEntry(
MetricsTable.TWENTY_FOUR_HOUR, hour0, scheduleId)), "Failed to update index for "
+ MetricsTable.TWENTY_FOUR_HOUR);
@@ -335,7 +337,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
// execute the system under test
metricsServer.setCurrentHour(hour24);
- metricsServer.calculateAggregates();
+ metricsServer.calculateAggregates(hour24.getMillis());
// verify the results
// verify that the 6 hour data is aggregated
@@ -343,7 +345,7 @@ public class MetricsServerTest extends CassandraIntegrationTest {
min1, max2, hour0.getMillis())));
// verify that the 24 hour queue is updated
- assert24HourMetricsIndexEmpty(scheduleId);
+ assert24HourMetricsIndexEmpty(scheduleId, hour0.getMillis());
}
@Test//(enabled = ENABLED)
@@ -758,8 +760,9 @@ public class MetricsServerTest extends CassandraIntegrationTest {
}
}
- private void assertMetricsIndexEquals(MetricsTable table, List<MetricsIndexEntry> expected, String msg) {
- List<MetricsIndexEntry> actual = Lists.newArrayList(dao.findMetricsIndexEntries(table));
+ private void assertMetricsIndexEquals(MetricsTable table, long timeSlice, List<MetricsIndexEntry> expected,
+ String msg) {
+ List<MetricsIndexEntry> actual = Lists.newArrayList(dao.findMetricsIndexEntries(table, timeSlice));
assertCollectionMatchesNoOrder(msg + ": " + table + " index does not match expected values.",
expected, actual);
}
@@ -797,20 +800,20 @@ public class MetricsServerTest extends CassandraIntegrationTest {
" but found " + metrics);
}
- private void assert1HourMetricsIndexEmpty(int scheduleId) {
- assertMetricsIndexEmpty(scheduleId, MetricsTable.ONE_HOUR);
+ private void assert1HourMetricsIndexEmpty(int scheduleId, long timeSlice) {
+ assertMetricsIndexEmpty(scheduleId, MetricsTable.ONE_HOUR, timeSlice);
}
- private void assert6HourMetricsIndexEmpty(int scheduleId) {
- assertMetricsIndexEmpty(scheduleId, MetricsTable.SIX_HOUR);
+ private void assert6HourMetricsIndexEmpty(int scheduleId, long timeSlice) {
+ assertMetricsIndexEmpty(scheduleId, MetricsTable.SIX_HOUR, timeSlice);
}
- private void assert24HourMetricsIndexEmpty(int scheduleId) {
- assertMetricsIndexEmpty(scheduleId, MetricsTable.TWENTY_FOUR_HOUR);
+ private void assert24HourMetricsIndexEmpty(int scheduleId, long timeSlice) {
+ assertMetricsIndexEmpty(scheduleId, MetricsTable.TWENTY_FOUR_HOUR, timeSlice);
}
- private void assertMetricsIndexEmpty(int scheduleId, MetricsTable table) {
- List<MetricsIndexEntry> index = Lists.newArrayList(dao.findMetricsIndexEntries(table));
+ private void assertMetricsIndexEmpty(int scheduleId, MetricsTable table, long timeSlice) {
+ List<MetricsIndexEntry> index = Lists.newArrayList(dao.findMetricsIndexEntries(table, timeSlice));
assertEquals(index.size(), 0, "Expected metrics index for " + table + " to be empty but found " + index);
}
diff --git a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/MeasurementAggregator.java b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/MeasurementAggregator.java
index 31bca0b..06d6b6b 100644
--- a/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/MeasurementAggregator.java
+++ b/modules/helpers/metrics-simulator/src/main/java/org/rhq/metrics/simulator/MeasurementAggregator.java
@@ -54,7 +54,7 @@ public class MeasurementAggregator implements Runnable {
log.info("Starting metrics aggregation...");
long startTime = System.currentTimeMillis();
try {
- metricsServer.calculateAggregates();
+ metricsServer.calculateAggregates(startTime);
} catch (Exception e) {
log.error("An error occurred while trying to perform aggregation", e);
log.error("Requesting simulation shutdown...");
commit f252084ba7f93f44cdfecef98f487817cca950bf
Author: John Sanda <jsanda(a)redhat.com>
Date: Sat May 18 11:09:18 2013 -0400
adding rhq.cassandra.start_rpc property for token replacement in cassandra.yaml
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
index 0e0ac3d..977a108 100644
--- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
+++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra.yaml
@@ -342,7 +342,7 @@ native_transport_max_threads: ${rhq.cassandra.native_transport_max_threads}
# Whether to start the thrift rpc server.
-start_rpc: false
+start_rpc: ${rhq.cassandra.start_rpc}
# The address to bind the Thrift RPC service to -- clients connect
# here. Unlike ListenAddress above, you *can* specify 0.0.0.0 here if
# you want Thrift to listen on all interfaces.
11 years
[rhq] modules/enterprise
by mazz
modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit edaffb818aec221eb0db5338fcf2e669b06e5a70
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Fri May 17 17:09:35 2013 -0400
BZ 963982 - make sure we persist the token when the registration was successful, even if the server endpoint was bad
diff --git a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
index 6e1a95a..a8d8bdf 100644
--- a/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
+++ b/modules/enterprise/agent/src/main/java/org/rhq/enterprise/agent/AgentMain.java
@@ -1376,6 +1376,7 @@ public class AgentMain {
try {
AgentRegistrationResults results = remote_pojo.registerAgent(request);
failover_list = results.getFailoverList();
+ token = results.getAgentToken(); // make sure our finally block gets this - BZ 963982
// Try to do a simple connect to each server in the failover list
// If only some of the servers are unreachable, just keep going;
@@ -1407,7 +1408,6 @@ public class AgentMain {
m_registration = results;
got_registered = true;
retry = false;
- token = results.getAgentToken();
LOG.info(AgentI18NResourceKeys.AGENT_REGISTRATION_RESULTS, results);
} finally {
// stores the new one if successful; restores the old one if we failed for some reason to register
11 years
[rhq] Branch 'feature/cassandra-backend' - 4 commits - modules/enterprise modules/plugins
by snegrea
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java | 5
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigrator.java | 140 ++++++++--
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java | 9
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingDataSource.java | 2
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingPostgresDataBulkExportSource.java | 20 +
modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ScrollableDataSource.java | 27 +
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeDiscoveryComponent.java | 25 +
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java | 1
modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml | 1
modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeDiscoveryComponent.java | 12
10 files changed, 184 insertions(+), 58 deletions(-)
New commits:
commit 5156415826bd7e5c673afe4b1cda9b22a37deaf0
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri May 17 15:34:46 2013 -0500
Clip unused line.
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
index 7599303..861464b 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/StorageServiceComponent.java
@@ -59,7 +59,6 @@ public class StorageServiceComponent extends ComplexConfigurationResourceCompone
AvailabilityType availability = UP;
-// EmsAttribute thriftEnabledAttr = emsBean.getAttribute("RPCServerRunning");
EmsAttribute nativeTransportEnabledAttr = emsBean.getAttribute("NativeTransportRunning");
Boolean nativeTransportEnabled = (Boolean) nativeTransportEnabledAttr.getValue();
commit abd8c2199661044a7c5307539e28e7a18fd9ddd8
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri May 17 15:34:35 2013 -0500
[BZ 958898] Update the estimation process to avoid count(*) timeouts. Also, improved the estimation process by not counting the non-migration time (eg. query preparation) as part of the variable time estimation.
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigrator.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigrator.java
index 2403062..148f82f 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigrator.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigrator.java
@@ -37,8 +37,10 @@ import com.datastax.driver.core.Session;
import com.datastax.driver.core.querybuilder.Batch;
import com.datastax.driver.core.querybuilder.QueryBuilder;
+import org.apache.commons.lang.time.StopWatch;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.hibernate.StatelessSession;
import org.rhq.server.metrics.domain.AggregateType;
import org.rhq.server.metrics.domain.MetricsTable;
@@ -61,8 +63,9 @@ public class DataMigrator {
private static final int MAX_RAW_BATCH_TO_CASSANDRA = 100;
private static final int MAX_AGGREGATE_BATCH_TO_CASSANDRA = 50;
private static final int MAX_NUMBER_OF_FAILURES = 5;
- private static final long NUMBER_OF_BATCHES_FOR_ESTIMATION = 4;
- private static final double UNDER_ESTIMATION_FACTOR = .10;
+ private static final int NUMBER_OF_BATCHES_FOR_ESTIMATION = 4;
+ private static final double UNDER_ESTIMATION_FACTOR = .15;
+ public static final int SQL_TIMEOUT = 6000000;
private enum MigrationQuery {
@@ -74,7 +77,6 @@ public class DataMigrator {
DELETE_6H_DATA("DELETE FROM RHQ_MEASUREMENT_DATA_NUM_6H"),
DELETE_1D_DATA("DELETE FROM RHQ_MEASUREMENT_DATA_NUM_1D"),
-
COUNT_1H_DATA("SELECT COUNT(*) FROM RHQ_MEASUREMENT_DATA_NUM_1H"),
COUNT_6H_DATA("SELECT COUNT(*) FROM RHQ_MEASUREMENT_DATA_NUM_6H"),
COUNT_1D_DATA("SELECT COUNT(*) FROM RHQ_MEASUREMENT_DATA_NUM_1D"),
@@ -309,24 +311,69 @@ public class DataMigrator {
return tables;
}
- private ExistingDataSource getExistingDataSource(EntityManager entityManager, String query) {
- if (this.databaseType == DatabaseType.Oracle) {
- return new ScrollableDataSource(entityManager, query);
- } else {
- if (!experimentalDataSource) {
+ private ExistingDataSource getExistingDataSource(EntityManager entityManager, String query, Task task) {
+
+ if (Task.Migrate.equals(task)) {
+ if (this.databaseType == DatabaseType.Oracle) {
return new ScrollableDataSource(entityManager, query);
} else {
- return new ExistingPostgresDataBulkExportSource(entityManager, query);
+ if (!experimentalDataSource) {
+ return new ScrollableDataSource(entityManager, query);
+ } else {
+ return new ExistingPostgresDataBulkExportSource(entityManager, query);
+ }
+ }
+ } else if (Task.Estimate.equals(task)) {
+ int limit = MAX_RECORDS_TO_LOAD_FROM_SQL * (NUMBER_OF_BATCHES_FOR_ESTIMATION + 1);
+
+ if (this.databaseType == DatabaseType.Oracle) {
+ return new ScrollableDataSource(entityManager, query, limit);
+ } else {
+ if (!experimentalDataSource) {
+ return new ScrollableDataSource(entityManager, query, limit);
+ } else {
+ return new ExistingPostgresDataBulkExportSource(entityManager, query, limit);
+ }
}
}
- //return new ExistingDataJPASource(entityManager, query);
+ return new ScrollableDataSource(entityManager, query);
}
private enum Task {
Migrate, Estimate
}
+ private class Telemetry {
+ private StopWatch generalTimer;
+ private StopWatch migrationTimer;
+
+ public Telemetry() {
+ this.generalTimer = new StopWatch();
+ this.migrationTimer = new StopWatch();
+ }
+
+ public StopWatch getGeneralTimer() {
+ return generalTimer;
+ }
+
+ public StopWatch getMigrationTimer() {
+ return migrationTimer;
+ }
+
+ public long getMigrationTime() {
+ return migrationTimer.getTime();
+ }
+
+ public long getGeneralTime() {
+ return generalTimer.getTime();
+ }
+
+ public long getNonMigrationTime() {
+ return this.getGeneralTime() - this.getMigrationTime();
+ }
+ }
+
private interface CallableMigrationWorker {
@@ -372,12 +419,16 @@ public class DataMigrator {
@Override
public long estimate() throws Exception {
- Query nativeQuery = entityManager.createNativeQuery(this.countQuery);
- long recordCount = Long.parseLong(nativeQuery.getSingleResult().toString());
- long estimatedTimeToMigrate = this.performMigration(Task.Estimate);
+ long recordCount = this.getRowCount(this.countQuery);
- long estimation = (recordCount / (long) MAX_RECORDS_TO_LOAD_FROM_SQL / NUMBER_OF_BATCHES_FOR_ESTIMATION)
+ Telemetry telemetry = this.performMigration(Task.Estimate);
+ long estimatedTimeToMigrate = telemetry.getMigrationTime();
+
+ long estimation = (recordCount / (long) MAX_RECORDS_TO_LOAD_FROM_SQL / (long) NUMBER_OF_BATCHES_FOR_ESTIMATION)
* estimatedTimeToMigrate;
+
+ estimation += telemetry.getNonMigrationTime();
+
return estimation;
}
@@ -388,6 +439,17 @@ public class DataMigrator {
}
}
+ private long getRowCount(String countQuery) {
+ StatelessSession session = ((org.hibernate.Session) entityManager.getDelegate())
+ .getSessionFactory().openStatelessSession();
+
+ org.hibernate.Query query = session.createSQLQuery(countQuery);
+ query.setReadOnly(true);
+ query.setTimeout(SQL_TIMEOUT);
+
+ return Long.parseLong(query.uniqueResult().toString());
+ }
+
private void deleteTableData() throws Exception {
int failureCount = 0;
while (failureCount < MAX_NUMBER_OF_FAILURES) {
@@ -409,17 +471,20 @@ public class DataMigrator {
}
}
- private long performMigration(Task task) throws Exception {
- long migrationStartTime = System.currentTimeMillis();
+ private Telemetry performMigration(Task task) throws Exception {
+ Telemetry telemetry = new Telemetry();
+ telemetry.getGeneralTimer().start();
+
long numberOfBatchesMigrated = 0;
List<Object[]> existingData;
int failureCount;
int lastMigratedRecord = 0;
- ExistingDataSource dataSource = getExistingDataSource(entityManager, selectQuery);
+ ExistingDataSource dataSource = getExistingDataSource(entityManager, selectQuery, task);
dataSource.initialize();
+ telemetry.getMigrationTimer().start();
while (true) {
existingData = dataSource.getData(lastMigratedRecord, MAX_RECORDS_TO_LOAD_FROM_SQL);
@@ -453,10 +518,12 @@ public class DataMigrator {
break;
}
}
+ telemetry.getMigrationTimer().stop();
dataSource.close();
+ telemetry.getGeneralTimer().stop();
- return System.currentTimeMillis() - migrationStartTime;
+ return telemetry;
}
private void insertDataToCassandra(List<Object[]> existingData)
@@ -529,13 +596,15 @@ public class DataMigrator {
long recordCount = 0;
for (String table : getRawDataTables()) {
String countQuery = String.format(MigrationQuery.COUNT_RAW.toString(), table);
- Query nativeQuery = entityManager.createNativeQuery(countQuery);
- recordCount += Long.parseLong(nativeQuery.getSingleResult().toString());
+ recordCount += this.getRowCount(countQuery);
}
- long estimatedTimeToMigrate = this.performMigration(Task.Estimate);
- long estimation = (recordCount / (long) MAX_RECORDS_TO_LOAD_FROM_SQL / NUMBER_OF_BATCHES_FOR_ESTIMATION)
+ Telemetry telemetry = this.performMigration(Task.Estimate);
+ long estimatedTimeToMigrate = telemetry.getMigrationTime();
+ long estimation = (recordCount / (long) MAX_RECORDS_TO_LOAD_FROM_SQL / (long) NUMBER_OF_BATCHES_FOR_ESTIMATION)
* estimatedTimeToMigrate;
+ estimation += telemetry.getNonMigrationTime();
+
return estimation;
}
@@ -543,23 +612,40 @@ public class DataMigrator {
performMigration(Task.Migrate);
}
- private long performMigration(Task task) throws Exception {
- long migrationStartTime = System.currentTimeMillis();
+ private long getRowCount(String countQuery) {
+ StatelessSession session = ((org.hibernate.Session) entityManager.getDelegate()).getSessionFactory()
+ .openStatelessSession();
+
+ org.hibernate.Query query = session.createSQLQuery(countQuery);
+ query.setReadOnly(true);
+ query.setTimeout(SQL_TIMEOUT);
+
+ return Long.parseLong(query.uniqueResult().toString());
+ }
+
+ private Telemetry performMigration(Task task) throws Exception {
+ Telemetry telemetry = new Telemetry();
+ telemetry.getGeneralTimer().start();
+
long numberOfBatchesMigrated = 0;
List<Object[]> existingData;
int failureCount;
+ telemetry.getMigrationTimer().start();
+ telemetry.getMigrationTimer().suspend();
+
while (!tablesNotProcessed.isEmpty()) {
String table = tablesNotProcessed.peek();
String selectQuery = String.format(MigrationQuery.SELECT_RAW_DATA.toString(), table);
- ExistingDataSource dataSource = getExistingDataSource(entityManager, selectQuery);
+ ExistingDataSource dataSource = getExistingDataSource(entityManager, selectQuery, task);
dataSource.initialize();
log.info("Start migrating raw table: " + table);
+ telemetry.getMigrationTimer().resume();
int lastMigratedRecord = 0;
while (true) {
existingData = dataSource.getData(lastMigratedRecord, MAX_RECORDS_TO_LOAD_FROM_SQL);
@@ -595,6 +681,7 @@ public class DataMigrator {
break;
}
}
+ telemetry.getMigrationTimer().suspend();
if (Task.Migrate.equals(task)) {
log.info("Done migrating raw table" + table + "---------------------");
@@ -610,7 +697,8 @@ public class DataMigrator {
tablesNotProcessed.poll();
}
- return System.currentTimeMillis() - migrationStartTime;
+ telemetry.getGeneralTimer().stop();
+ return telemetry;
}
private void deleteTableData(String table) throws Exception {
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
index d5b3f86..3d9eb9d 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/DataMigratorRunner.java
@@ -70,11 +70,8 @@ import org.rhq.server.metrics.migrator.DataMigrator.DatabaseType;
@SuppressWarnings({ "static-access", "deprecation" })
public class DataMigratorRunner {
- private static final int SQL_TIMEOUT = 40000;
-
private final Log log = LogFactory.getLog(DataMigratorRunner.class);
-
//Cassandra
private Option cassandraUserOption = OptionBuilder.withLongOpt("cassandra-user").hasArg().withType(String.class)
.withDescription("Cassandra user (default: rhqadmin)").create();
@@ -578,8 +575,8 @@ public class DataMigratorRunner {
properties.put("javax.persistence.provider", "org.hibernate.ejb.HibernatePersistence");
properties.put("hibernate.connection.username", (String) configuration.get(sqlUserOption));
properties.put("hibernate.connection.password", (String) configuration.get(sqlPasswordOption));
- properties.put("javax.persistence.query.timeout", SQL_TIMEOUT);
- properties.put("hibernate.c3p0.timeout", SQL_TIMEOUT);
+ properties.put("javax.persistence.query.timeout", DataMigrator.SQL_TIMEOUT);
+ properties.put("hibernate.c3p0.timeout", DataMigrator.SQL_TIMEOUT);
if ("oracle".equals(configuration.get(sqlServerType))) {
String driverClassName = "oracle.jdbc.driver.OracleDriver";
@@ -598,7 +595,7 @@ public class DataMigratorRunner {
properties.put("hibernate.connection.url", "jdbc:oracle:thin:@" + (String) configuration.get(sqlHostOption)
+ ":" + (String) configuration.get(sqlPortOption) + ":" + (String) configuration.get(sqlDBOption));
properties.put("hibernate.default_schema", (String) configuration.get(sqlDBOption));
- properties.put("hibernate.connection.oracle.jdbc.ReadTimeout", SQL_TIMEOUT);
+ properties.put("hibernate.connection.oracle.jdbc.ReadTimeout", DataMigrator.SQL_TIMEOUT);
} else {
String driverClassName = "org.postgresql.Driver";
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingDataSource.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingDataSource.java
index 0096538..033c5d9 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingDataSource.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingDataSource.java
@@ -26,6 +26,8 @@ import java.util.List;
*/
public interface ExistingDataSource {
+ static final int TIMEOUT = 6000000;
+
List<Object[]> getData(int fromIndex, int maxResults) throws Exception;
void initialize() throws Exception;
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingPostgresDataBulkExportSource.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingPostgresDataBulkExportSource.java
index 563e332..2ba7e4a 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingPostgresDataBulkExportSource.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ExistingPostgresDataBulkExportSource.java
@@ -39,13 +39,19 @@ import org.rhq.core.util.stream.StreamUtil;
*/
public class ExistingPostgresDataBulkExportSource extends ExistingDataBulkExportSource {
- private EntityManager entityManager;
- private String selectNativeQuery;
+ private final EntityManager entityManager;
+ private final String selectNativeQuery;
+ private final int maxResults;
public ExistingPostgresDataBulkExportSource(EntityManager entityManager, String selectNativeQuery) {
+ this(entityManager, selectNativeQuery, -1);
+ }
+
+ public ExistingPostgresDataBulkExportSource(EntityManager entityManager, String selectNativeQuery, int maxResults) {
super();
this.entityManager = entityManager;
this.selectNativeQuery = selectNativeQuery;
+ this.maxResults = maxResults;
}
protected void exportExistingData() throws Exception {
@@ -58,8 +64,14 @@ public class ExistingPostgresDataBulkExportSource extends ExistingDataBulkExport
ConnectionProvider cp = sfi.getConnectionProvider();
connection = cp.getConnection();
CopyManager copyManager = new CopyManager((BaseConnection) connection);
- copyManager.copyOut("COPY (" + this.selectNativeQuery + ") TO STDOUT WITH DELIMITER '" + DELIMITER + "'",
- fileWriter);
+
+ if (maxResults > 0) {
+ copyManager.copyOut("COPY (" + selectNativeQuery + " LIMIT " + maxResults
+ + ") TO STDOUT WITH DELIMITER '" + DELIMITER + "'", fileWriter);
+ } else {
+ copyManager.copyOut("COPY (" + selectNativeQuery + ") TO STDOUT WITH DELIMITER '" + DELIMITER + "'",
+ fileWriter);
+ }
} finally {
StreamUtil.safeClose(fileWriter);
JDBCUtil.safeClose(connection);
diff --git a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ScrollableDataSource.java b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ScrollableDataSource.java
index 23f1e41..09215b8 100644
--- a/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ScrollableDataSource.java
+++ b/modules/enterprise/server/server-metrics/src/main/java/org/rhq/server/metrics/migrator/ScrollableDataSource.java
@@ -37,18 +37,25 @@ import org.hibernate.StatelessSession;
*/
public class ScrollableDataSource implements ExistingDataSource {
- private static final Log log = LogFactory.getLog(ExistingDataJPASource.class);
+ private static final Log log = LogFactory.getLog(ScrollableDataSource.class);
- private EntityManager entityManager;
- private String selectNativeQuery;
+ private final EntityManager entityManager;
+ private final String selectNativeQuery;
+ private final int maxResults;
private ScrollableResults results;
private StatelessSession session;
private int lastMigratedItemIndex;
+
public ScrollableDataSource(EntityManager entityManager, String selectNativeQuery) {
+ this(entityManager, selectNativeQuery, -1);
+ }
+
+ public ScrollableDataSource(EntityManager entityManager, String selectNativeQuery, int maxResults) {
this.entityManager = entityManager;
this.selectNativeQuery = selectNativeQuery;
+ this.maxResults = maxResults;
}
@Override
@@ -83,17 +90,29 @@ public class ScrollableDataSource implements ExistingDataSource {
@Override
public void initialize() {
if (session != null || results != null) {
- this.close();
+ close();
}
session = ((Session) entityManager.getDelegate()).getSessionFactory().openStatelessSession();
+ if (log.isDebugEnabled()) {
+ log.debug("Preparing the query with " + maxResults + " results.");
+ }
+
Query query = session.createSQLQuery(selectNativeQuery);
+ if (maxResults > 0) {
+ query.setMaxResults(maxResults);
+ }
query.setFetchSize(30000);
query.setReadOnly(true);
+ query.setTimeout(TIMEOUT);
results = query.scroll(ScrollMode.FORWARD_ONLY);
lastMigratedItemIndex = -1;
+
+ if (log.isDebugEnabled()) {
+ log.debug("Query prepared with " + maxResults + " results.");
+ }
}
@Override
commit f9edb9a67857238cd8544f55ba93816e3025ab37
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri May 17 11:02:20 2013 -0500
[BZ 964229] Remove tokens trait since it gets large with virtual nodes enabled. The information is still avaiable via the tokens to endpoint map property.
diff --git a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
index 0820e84..edc3950 100644
--- a/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
+++ b/modules/plugins/cassandra/src/main/resources/META-INF/rhq-plugin.xml
@@ -186,7 +186,6 @@
in the system.schema_* column families. This value is used in an algorithm to compare schema versions
between nodes and apply updates as necessary. This value should be the same for all fully initialized
nodes in the cluster."/>
- <metric property="Tokens" dataType="trait" displayType="summary" description="A string representation of this node's token" defaultOn="true"/>
<resource-configuration>
<c:group name="DataStorage">
commit b964af8791e96bd17c55de0bf88f38312d3e13e3
Author: Stefan Negrea <snegrea(a)redhat.com>
Date: Fri May 17 10:59:04 2013 -0500
Update storage manager bean to link to RHQ storage node resources. Plus a few minor updates to the plugin to expose functionality to inheriting classes.
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
index b924bcc..49f8dde 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/cloud/StorageNodeManagerBean.java
@@ -61,6 +61,9 @@ import org.rhq.server.metrics.CQLException;
@Stateless
public class StorageNodeManagerBean implements StorageNodeManagerLocal {
+ private static final String RESOURCE_TYPE_NAME = "RHQ Storage Node";
+ private static final String PLUGIN_NAME = "RHQStorage";
+
@PersistenceContext(unitName = RHQConstants.PERSISTENCE_UNIT_NAME)
private EntityManager entityManager;
@@ -120,7 +123,7 @@ public class StorageNodeManagerBean implements StorageNodeManagerLocal {
@SuppressWarnings("unchecked")
private void discoverResourceInformation(Map<String, StorageNode> storageNodeMap) {
Query query = entityManager.createNamedQuery(ResourceType.QUERY_FIND_BY_NAME_AND_PLUGIN)
- .setParameter("name", "Cassandra Daemon").setParameter("plugin", "Cassandra");
+ .setParameter("name", RESOURCE_TYPE_NAME).setParameter("plugin", PLUGIN_NAME);
List<ResourceType> resourceTypes = (List<ResourceType>) query.getResultList();
if (resourceTypes.isEmpty()) {
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeDiscoveryComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeDiscoveryComponent.java
index 8ad7a61..cd5e64e 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeDiscoveryComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeDiscoveryComponent.java
@@ -52,8 +52,16 @@ public class CassandraNodeDiscoveryComponent extends JMXDiscoveryComponent {
protected static final String HOST_PROPERTY = "host";
protected static final String CLUSTER_NAME_PROPERTY = "clusterName";
+ protected static final String NATIVE_TRANSPORT_PORT_PROPERTY = "nativeTransportPort";
+ protected static final String AUTHENTICATOR_PROPERTY = "authenticator";
+ protected static final String USERNAME_PROPERTY = "username";
+ protected static final String PASSWORD_PROPERTY = "password";
+
+ protected static final String DEFAULT_RHQ_CLUSTER = "rhq";
+
private static final String RESOURCE_NAME = "Cassandra";
+
@SuppressWarnings({ "rawtypes" })
@Override
public Set<DiscoveredResourceDetails> discoverResources(ResourceDiscoveryContext context) {
@@ -84,7 +92,8 @@ public class CassandraNodeDiscoveryComponent extends JMXDiscoveryComponent {
}
protected boolean isCassandraNode(DiscoveredResourceDetails discoveredResource) {
- if ("rhq".equals(discoveredResource.getPluginConfiguration().getSimpleValue(CLUSTER_NAME_PROPERTY))) {
+ if (DEFAULT_RHQ_CLUSTER.equals(discoveredResource.getPluginConfiguration()
+ .getSimpleValue(CLUSTER_NAME_PROPERTY))) {
return false;
}
@@ -158,12 +167,13 @@ public class CassandraNodeDiscoveryComponent extends JMXDiscoveryComponent {
}
if (parsedProperties.get("native_transport_port") != null) {
- pluginConfig.put(new PropertySimple("nativeTransportPort", parsedProperties
+ pluginConfig.put(new PropertySimple(NATIVE_TRANSPORT_PORT_PROPERTY, parsedProperties
.get("native_transport_port")));
}
if (parsedProperties.get("authenticator") != null) {
- pluginConfig.put(new PropertySimple("authenticator", parsedProperties.get("authenticator")));
+ pluginConfig.put(new PropertySimple(AUTHENTICATOR_PROPERTY, parsedProperties
+ .get("authenticator")));
}
} catch (Exception e) {
log.error("YAML Configuration load exception ", e);
@@ -183,17 +193,18 @@ public class CassandraNodeDiscoveryComponent extends JMXDiscoveryComponent {
pluginConfig.put(new PropertySimple(JMXDiscoveryComponent.CONNECTION_TYPE,
J2SE5ConnectionTypeDescriptor.class.getName()));
pluginConfig.put(new PropertySimple(JMXDiscoveryComponent.CONNECTOR_ADDRESS_CONFIG_PROPERTY,
- "service:jmx:rmi:///jndi/rmi://" + pluginConfig.getSimpleValue("host") + ":" + jmxPort + "/jmxrmi"));
+ "service:jmx:rmi:///jndi/rmi://" + pluginConfig.getSimpleValue(HOST_PROPERTY) + ":" + jmxPort
+ + "/jmxrmi"));
}
- String resourceKey = "Cassandra (" + pluginConfig.getSimpleValue("host") + ") " + jmxPort;
+ String resourceKey = "Cassandra (" + pluginConfig.getSimpleValue(HOST_PROPERTY) + ") " + jmxPort;
String resourceName = RESOURCE_NAME;
String path = processInfo.getExecutable().getCwd();
pluginConfig.put(new PropertySimple("baseDir", new File(path).getParentFile().getAbsolutePath()));
- pluginConfig.put(new PropertySimple("username", "cassandra"));
- pluginConfig.put(new PropertySimple("password", "cassandra"));
+ pluginConfig.put(new PropertySimple(USERNAME_PROPERTY, "cassandra"));
+ pluginConfig.put(new PropertySimple(PASSWORD_PROPERTY, "cassandra"));
return new DiscoveredResourceDetails(context.getResourceType(), resourceKey, resourceName, null, null,
pluginConfig, processInfo);
diff --git a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeDiscoveryComponent.java b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeDiscoveryComponent.java
index 910bb54..3a44ea6 100644
--- a/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeDiscoveryComponent.java
+++ b/modules/plugins/rhq-storage/src/main/java/org/rhq/plugins/storage/StorageNodeDiscoveryComponent.java
@@ -25,9 +25,6 @@ package org.rhq.plugins.storage;
import java.util.HashSet;
import java.util.Set;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import org.rhq.core.domain.configuration.Configuration;
import org.rhq.core.pluginapi.inventory.DiscoveredResourceDetails;
import org.rhq.core.pluginapi.inventory.ResourceDiscoveryContext;
@@ -38,8 +35,6 @@ import org.rhq.plugins.cassandra.CassandraNodeDiscoveryComponent;
*/
public class StorageNodeDiscoveryComponent extends CassandraNodeDiscoveryComponent {
- private static final Log log = LogFactory.getLog(CassandraNodeDiscoveryComponent.class);
-
private static final String RESOURCE_NAME = "RHQ Storage Node";
@SuppressWarnings({ "rawtypes" })
@@ -49,11 +44,12 @@ public class StorageNodeDiscoveryComponent extends CassandraNodeDiscoveryCompone
Set<DiscoveredResourceDetails> storageNodes = new HashSet<DiscoveredResourceDetails>();
for (DiscoveredResourceDetails discoveredResource : discoveredResources) {
- Configuration test = discoveredResource.getPluginConfiguration();
+ Configuration configuration = discoveredResource.getPluginConfiguration();
if (!isCassandraNode(discoveredResource)) {
- String resourceKey = "RHQ Storage (" + test.getSimpleValue(HOST_PROPERTY, "localhost") + ")";
- String resourceName = StorageNodeDiscoveryComponent.RESOURCE_NAME;
+ String resourceKey = StorageNodeDiscoveryComponent.RESOURCE_NAME + "("
+ + configuration.getSimpleValue(HOST_PROPERTY, "localhost") + ")";
+ String resourceName = resourceKey;
discoveredResource.setResourceKey(resourceKey);
discoveredResource.setResourceName(resourceName);
11 years
[rhq] Branch 'feature/cassandra-backend' - 2 commits - modules/enterprise modules/plugins
by John Sanda
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java | 90 +++++-----
modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java | 6
2 files changed, 56 insertions(+), 40 deletions(-)
New commits:
commit f48f0cf291c90c1615e63fbf367d65d193e850d8
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri May 17 10:46:09 2013 -0400
[BZ 958087] shut down cluster object so agent can shutdown gracefully
diff --git a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
index a29c7a3..cbbdcf6 100644
--- a/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
+++ b/modules/plugins/cassandra/src/main/java/org/rhq/plugins/cassandra/CassandraNodeComponent.java
@@ -104,6 +104,12 @@ public class CassandraNodeComponent extends JMXServerComponent<ResourceComponent
};
@Override
+ public void stop() {
+ log.info("Shutting down");
+ cassandraSession.getCluster().shutdown();
+ }
+
+ @Override
public AvailabilityType getAvailability() {
ResourceContext<?> context = getResourceContext();
ProcessInfo processInfo = context.getNativeProcess();
commit 956945b76276c98df268f3e3320528f40da79cab
Author: John Sanda <jsanda(a)redhat.com>
Date: Fri May 17 10:40:15 2013 -0400
adding debug logging
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java
index 1226d99..eecbbca 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/measurement/MeasurementOOBManagerBean.java
@@ -192,54 +192,64 @@ public class MeasurementOOBManagerBean implements MeasurementOOBManagerLocal {
@SuppressWarnings("unchecked")
public void computeOOBsForLastHour(Subject subject, Iterable<AggregateNumericMetric> metrics) {
- for (AggregateNumericMetric metric : metrics) {
- try {
- List<MeasurementBaseline> baselines = entityManager.createQuery(
- "select baseline from MeasurementBaseline baseline where baseline.schedule.id = :scheduleId")
- .setParameter("scheduleId", metric.getScheduleId())
- .getResultList();
- if (baselines.isEmpty()) {
- continue;
- }
- MeasurementBaseline baseline = baselines.get(0);
- Long upperDelta = null;
- Long lowerDelta = null;
+ int count = 0;
+ long startTime = System.currentTimeMillis();
+ try {
+ for (AggregateNumericMetric metric : metrics) {
+ try {
+ List<MeasurementBaseline> baselines = entityManager.createQuery(
+ "select baseline from MeasurementBaseline baseline where baseline.schedule.id = :scheduleId")
+ .setParameter("scheduleId", metric.getScheduleId())
+ .getResultList();
+ if (baselines.isEmpty()) {
+ continue;
+ }
+ MeasurementBaseline baseline = baselines.get(0);
+ Long upperDelta = null;
+ Long lowerDelta = null;
- if (isPastUpperBound(baseline, metric)) {
- upperDelta =
- Math.round(((metric.getMax() - baseline.getMax()) / (baseline.getMax() - baseline.getMin())) * 100);
- }
+ if (isPastUpperBound(baseline, metric)) {
+ upperDelta =
+ Math.round(((metric.getMax() - baseline.getMax()) / (baseline.getMax() - baseline.getMin())) * 100);
+ }
- if (isPastLowerBound(baseline, metric)) {
- lowerDelta =
- Math.round(((baseline.getMin() - metric.getMin()) / (baseline.getMax() - baseline.getMin())) * 100);
- }
+ if (isPastLowerBound(baseline, metric)) {
+ lowerDelta =
+ Math.round(((baseline.getMin() - metric.getMin()) / (baseline.getMax() - baseline.getMin())) * 100);
+ }
- Integer oobFactor;
- if (upperDelta != null && lowerDelta == null) {
- oobFactor = upperDelta.intValue();
- } else if (upperDelta == null && lowerDelta != null) {
- oobFactor = lowerDelta.intValue();
- } else if (upperDelta != null && lowerDelta != null) {
- if (upperDelta > lowerDelta) {
+ Integer oobFactor;
+ if (upperDelta != null && lowerDelta == null) {
oobFactor = upperDelta.intValue();
- } else {
+ } else if (upperDelta == null && lowerDelta != null) {
oobFactor = lowerDelta.intValue();
+ } else if (upperDelta != null && lowerDelta != null) {
+ if (upperDelta > lowerDelta) {
+ oobFactor = upperDelta.intValue();
+ } else {
+ oobFactor = lowerDelta.intValue();
+ }
+ } else { // both are null
+ oobFactor = null;
}
- } else { // both are null
- oobFactor = null;
- }
- if (oobFactor != null) {
- MeasurementOOB oob = new MeasurementOOB();
- oob.setScheduleId(metric.getScheduleId());
- oob.setTimestamp(metric.getTimestamp());
- oob.setOobFactor(oobFactor);
- entityManager.merge(oob);
+ if (oobFactor != null) {
+ MeasurementOOB oob = new MeasurementOOB();
+ oob.setScheduleId(metric.getScheduleId());
+ oob.setTimestamp(metric.getTimestamp());
+ oob.setOobFactor(oobFactor);
+ entityManager.merge(oob);
+ ++count;
+ }
+ } catch (Exception e) {
+ log.error("An error occurred while calculating OOBs for " + metric, e);
+ throw new RuntimeException(e);
}
- } catch (Exception e) {
- log.error("An error occurred while calculating OOBs for " + metric, e);
- throw new RuntimeException(e);
+ }
+ } finally {
+ long endTime = System.currentTimeMillis();
+ if (log.isDebugEnabled()) {
+ log.debug("Finished calculating " + count + " OOBs in " + (endTime - startTime) + " ms");
}
}
}
11 years
[rhq] 2 commits - modules/enterprise modules/integration-tests
by Heiko W. Rupp
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/ResourceHandlerBean.java | 4 +++
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java | 2 -
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/ResourcesTest.java | 11 ++++++++++
3 files changed, 16 insertions(+), 1 deletion(-)
New commits:
commit 92fd97dd84324980487972bda6f424114e1e712d
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 17 14:11:32 2013 +0200
BZ 962858 check passed resource id and return 404 if invalid
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 288e9f7..70cc588 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
@@ -559,6 +559,10 @@ public class ResourceHandlerBean extends AbstractRestBean {
@ApiOperation("Get a list of links to the alerts for the passed resource")
public List<Link> getAlertsForResource(@ApiParam("Id of the resource to query") @PathParam("id") int resourceId) {
AlertCriteria criteria = new AlertCriteria();
+
+ // Check for resource existence
+ fetchResource(resourceId);
+
criteria.addFilterResourceIds(resourceId);
List<Alert> alerts = alertManager.findAlertsByCriteria(caller, criteria);
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 3efd807..cc9558b 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
@@ -593,6 +593,17 @@ public class ResourcesTest extends AbstractBase {
}
@Test
+ public void testAlertsForUnknownResource() throws Exception {
+ given()
+ .header("Accept", "application/json")
+ .pathParam("id", 12345)
+ .expect()
+ .statusCode(404)
+ .when()
+ .get("/resource/{id}/alerts");
+ }
+
+ @Test
public void testSchedulesForResource() throws Exception {
given()
.header("Accept", "application/json")
commit b8207e9ec0efcf679af774e870f1c3b70fafc6fc
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Fri May 17 09:26:14 2013 +0200
Disable for the moment
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java
index 7e20630..3a7e961 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/configuration/ConfigurationHelperTest.java
@@ -703,7 +703,7 @@ public class ConfigurationHelperTest {
}
- @Test
+ @Test(enabled = false)
public void testConfigToMapComplexMapWithBadSetupLenient() throws Exception {
Configuration config = new Configuration();
11 years
[rhq] modules/enterprise
by Jiri Kremser
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java | 5 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java | 25 ++++++++--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java | 1
modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png |binary
modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png |binary
6 files changed, 22 insertions(+), 9 deletions(-)
New commits:
commit 9a040dd824209eb9e71bb22c7cf7d80a7c468485
Author: Jirka Kremser <jkremser(a)redhat.com>
Date: Fri May 17 12:41:31 2013 +0200
[BZ 958169] - Modified alert definition is not saved on confirming the save message after clicking on 'Back to List' button - Making the "Back to List" button disabled when editing the alert definition.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
index 14b6abf..d915cb0 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/EditAlertDefinitionForm.java
@@ -1,8 +1,5 @@
package org.rhq.enterprise.gui.coregui.client.alert.definitions;
-import java.util.Map;
-
-import org.rhq.core.domain.alert.AlertCondition;
import org.rhq.core.domain.alert.AlertDefinition;
/**
@@ -12,8 +9,6 @@ public interface EditAlertDefinitionForm {
AlertDefinition getAlertDefinition();
-// Map<Integer, AlertCondition> getUpdatedAlertConditions();
-
boolean isResetMatching();
void setAlertDefinition(AlertDefinition alertDef);
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
index b4504c9..c86d0cd 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/alert/definitions/SingleAlertDefinitionView.java
@@ -28,6 +28,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
import com.smartgwt.client.util.BooleanCallback;
import com.smartgwt.client.util.SC;
import com.smartgwt.client.widgets.Button;
+import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.events.VisibilityChangedEvent;
@@ -145,7 +146,10 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
- handlerRegistration.removeHandler();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
+ // enable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
setAlertDefinition(getAlertDefinition()); // reverts data back to original
makeViewOnly();
}
@@ -193,6 +197,8 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
recovery.makeEditable();
dampening.makeEditable();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
handlerRegistration = addVisibilityChangedHandler(new VisibilityChangedHandler() {
public void onVisibilityChanged(VisibilityChangedEvent event) {
if (!event.getIsVisible()) {
@@ -201,12 +207,15 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
if (value) {
save();
}
- handlerRegistration.removeHandler();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
}
});
}
}
});
+ // disable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(true);
}
public void makeViewOnly() {
@@ -240,13 +249,21 @@ public class SingleAlertDefinitionView extends EnhancedVLayout {
new AsyncCallback<AlertDefinition>() {
@Override
public void onSuccess(final AlertDefinition alertDef) {
- handlerRegistration.removeHandler();
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
setAlertDefinition(alertDef);
+ // enable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
}
@Override
public void onFailure(Throwable caught) {
- // nothing, the notification is done in the subclasses of AbstractAlertDefinitionsView
+ if (handlerRegistration != null)
+ handlerRegistration.removeHandler();
+ // enable the back button
+ ((EnhancedVLayout) getParentElement()).getMember("backButton").setDisabled(false);
+
+ // no error handling, the notification is done in the subclasses of AbstractAlertDefinitionsView
}
});
} else {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java
index efab26d..41819e1 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/buttons/BackButton.java
@@ -41,6 +41,7 @@ public class BackButton extends StretchImgButton {
public BackButton(String title, final String anchor) {
this();
setTitle("<b>" + title + "</b>");
+ setID("backButton");
addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
CoreGUI.goToView(anchor);
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png
new file mode 100644
index 0000000..c323816
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_end.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png
new file mode 100644
index 0000000..d6cf484
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_start.png differ
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png
new file mode 100644
index 0000000..2addd3a
Binary files /dev/null and b/modules/enterprise/gui/coregui/src/main/webapp/images/buttons/back/back_Disabled_stretch.png differ
11 years