modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
| 6 +
modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
| 36 ++++++++--
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
| 24 +++++-
3 files changed, 58 insertions(+), 8 deletions(-)
New commits:
commit f31f3b78faa0af69a0b01088d8db9c2997bafa02
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jan 2 14:17:25 2014 +0100
Compact properties and collections of properties. Detach resource config on receive
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
index 7113b35..e4b08c4 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/Configuration.java
@@ -851,6 +851,12 @@ public class Configuration implements Serializable, Cloneable,
AbstractPropertyM
}
}
+ public void resize() {
+ Map<String,Property> tmp =new LinkedHashMap<String,
Property>(this.properties.size());
+ tmp.putAll(this.properties);
+ this.properties=tmp;
+ }
+
public String getNotes() {
return notes;
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
index 746deea..f7fb1a3 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
@@ -65,6 +65,7 @@ import
org.rhq.core.clientapi.server.discovery.InvalidInventoryReportException;
import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.clientapi.server.discovery.StaleTypeException;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.Property;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeInventoryReportResults;
import org.rhq.core.domain.discovery.MergeInventoryReportResults.ResourceTypeFlyweight;
@@ -90,6 +91,7 @@ import org.rhq.core.pc.agent.AgentRegistrar;
import org.rhq.core.pc.agent.AgentService;
import org.rhq.core.pc.availability.AvailabilityContextImpl;
import org.rhq.core.pc.component.ComponentInvocationContextImpl;
+import org.rhq.core.pc.configuration.ConfigurationCheckExecutor;
import org.rhq.core.pc.content.ContentContextImpl;
import org.rhq.core.pc.drift.sync.DriftSyncManager;
import org.rhq.core.pc.event.EventContextImpl;
@@ -2992,12 +2994,13 @@ public class InventoryManager extends AgentService implements
ContainerService,
if (resource.getChildResources().isEmpty()) {
resource.setChildResources(Collections.EMPTY_SET);
}
-/* TODO comment this in again once we understand why this makes the tests fail
+/* TODO the next will make the tests fail
TODO I have not seen issues inside a real running agent - hrupp
-
+*/
Configuration pluginConfiguration = resource.getPluginConfiguration();
if (pluginConfiguration !=null ) {
pluginConfiguration.cleanoutRawConfiguration();
+ compactConfiguration(pluginConfiguration);
}
Configuration resourceConfiguration = resource.getResourceConfiguration();
@@ -3011,8 +3014,23 @@ public class InventoryManager extends AgentService implements
ContainerService,
}
}
-*/
+
+ }
+
+ private void compactConfiguration(Configuration config) {
+ if (config==null) {
+ return;
+ }
+ if (config.getProperties()==null) {
+ return;
+ }
+ for (Property prop : config.getProperties()) {
+ if (prop.getName()!=null) {
+ prop.setName(prop.getName().intern());
+ }
+ }
+ config.resize();
}
private void mergeModifiedResources(Set<Integer> modifiedResourceIds) {
commit 4ed365c83b1290b8af5e94903adbd09e36b7269e
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jan 2 14:14:55 2014 +0100
Do some lazy allocations of collections that are seldom used.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
index ea4080c..01994db 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/definition/PropertyDefinitionSimple.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright (C) 2005-2011 Red Hat, Inc.
+ * Copyright (C) 2005-2014 Red Hat, Inc.
* All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
@@ -23,6 +23,7 @@
package org.rhq.core.domain.configuration.definition;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -69,7 +70,7 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
@Cascade( { org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@OneToMany(mappedBy = "propertyDefinitionSimple", cascade = {
CascadeType.ALL }, fetch = FetchType.EAGER)
- private Set<Constraint> constraints = new HashSet<Constraint>();
+ private Set<Constraint> constraints = null;
/**
* The <options> within <property-options> for a <simple-property>
@@ -77,7 +78,7 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
@Cascade( { org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@IndexColumn(name = "order_index")
@OneToMany(mappedBy = "propertyDefinitionSimple", fetch = FetchType.EAGER)
- private List<PropertyDefinitionEnumeration> enumeratedValues = new
ArrayList<PropertyDefinitionEnumeration>();
+ private List<PropertyDefinitionEnumeration> enumeratedValues = null;
/**
* This property's default value. This field should have a non-null value for
properties whose
@@ -99,7 +100,7 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
@Cascade( { org.hibernate.annotations.CascadeType.ALL,
org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@OneToMany(mappedBy = "propertyDefinition", fetch = FetchType.EAGER)
- List<PropertyOptionsSource> optionsSource = new
ArrayList<PropertyOptionsSource>();
+ List<PropertyOptionsSource> optionsSource = null;
public PropertyDefinitionSimple(@NotNull String name, String description, boolean
required,
@NotNull PropertySimpleType type) {
@@ -126,10 +127,20 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
*/
@NotNull
public Set<Constraint> getConstraints() {
+ if (this.constraints==null) {
+ return Collections.EMPTY_SET;
+ }
return this.constraints;
}
public void setConstraints(Set<Constraint> constraints) {
+ if (constraints==null || constraints.isEmpty()) {
+ this.constraints=null;
+ return;
+ }
+ if (this.constraints==null) {
+ this.constraints = new HashSet<Constraint>(constraints.size());
+ }
for (Constraint constraint : constraints) {
getConstraints().add(constraint);
constraint.setPropertyDefinitionSimple(this);
@@ -137,6 +148,9 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
}
public void addConstraints(Constraint... constraintsToAdd) {
+ if (this.constraints==null) {
+ this.constraints = new HashSet<Constraint>(constraintsToAdd.length);
+ }
for (Constraint constraint : constraintsToAdd) {
getConstraints().add(constraint);
constraint.setPropertyDefinitionSimple(this);
@@ -149,6 +163,9 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
*/
@NotNull
public List<PropertyDefinitionEnumeration> getEnumeratedValues() {
+ if (this.enumeratedValues==null) {
+ return new ArrayList<PropertyDefinitionEnumeration>(1);
+ }
return this.enumeratedValues;
}
@@ -159,6 +176,9 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
}
public void addEnumeratedValues(PropertyDefinitionEnumeration... enumerations) {
+ if (this.enumeratedValues==null) {
+ this.enumeratedValues = new
ArrayList<PropertyDefinitionEnumeration>(1);
+ }
for (PropertyDefinitionEnumeration enumeration : enumerations) {
enumeration.setPropertyDefinitionSimple(this);
getEnumeratedValues().add(enumeration);
@@ -170,6 +190,9 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
for (PropertyDefinitionEnumeration enumeration : enumerations) {
getEnumeratedValues().remove(enumeration);
}
+ if (this.enumeratedValues.isEmpty()) {
+ this.enumeratedValues=null;
+ }
ensureOrdering();
}
@@ -243,12 +266,15 @@ public class PropertyDefinitionSimple extends PropertyDefinition {
}
public PropertyOptionsSource getOptionsSource() {
- if (optionsSource.isEmpty())
+ if (optionsSource==null || optionsSource.isEmpty())
return null;
return optionsSource.get(0);
}
public void setOptionsSource(PropertyOptionsSource source) {
+ if (this.optionsSource==null) {
+ optionsSource = new ArrayList<PropertyOptionsSource>(1);
+ }
this.optionsSource.clear();
if (source==null)
return;