modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
| 2 -
modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
| 20 +++++++++-
modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
| 2 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
| 2 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java
| 15 ++++---
modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
| 5 +-
modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
| 5 +-
7 files changed, 35 insertions(+), 16 deletions(-)
New commits:
commit 75329fce150ea3c9bd99e7f2824d17058c2848a9
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Feb 25 16:16:12 2014 -0500
[1069887] Manual add can create duplicate resources
When manually adding a resource the server instructs the agent to
discover the new resource, given plugin config. After discovery the
agent asks the server to merge the new resource into inventory (assigning
an id, etc). While the server is doing that, it was possible the new
resource could get picked up in an inventory sync because it looked
like the resource was dirty. This fixes that condition.
diff --git
a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
index 36fb392..c4d4a8a 100644
---
a/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
+++
b/modules/core/arquillian-integration/container/src/main/java/org/rhq/test/arquillian/FakeServerInventory.java
@@ -217,7 +217,7 @@ public class FakeServerInventory {
r = fakePersist(r, InventoryStatus.COMMITTED, new
HashSet<String>());
- return new MergeResourceResponse(r.getId(), exists);
+ return new MergeResourceResponse(r.getId(), (exists ? r.getMtime() :
r.getCtime()), exists);
}
};
}
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
index 1658165..7f477a4 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/discovery/MergeResourceResponse.java
@@ -34,11 +34,25 @@ public class MergeResourceResponse implements Serializable {
private static final long serialVersionUID = 1L;
private int resourceId;
-
+ private long mtime;
private boolean resourceAlreadyExisted;
+ /**
+ * @deprecated use {@link #MergeResourceResponse(int, long, boolean)}
+ */
+ @Deprecated
public MergeResourceResponse(int resourceId, boolean resourceAlreadyExisted) {
+ this(resourceId, 0L, resourceAlreadyExisted);
+ }
+
+ /**
+ * @param resourceId
+ * @param mtime for new resources, this is the ctime, for existing resources it is
the mtime
+ * @param resourceAlreadyExisted
+ */
+ public MergeResourceResponse(int resourceId, long mtime, boolean
resourceAlreadyExisted) {
this.resourceId = resourceId;
+ this.mtime = mtime;
this.resourceAlreadyExisted = resourceAlreadyExisted;
}
@@ -46,6 +60,10 @@ public class MergeResourceResponse implements Serializable {
return resourceId;
}
+ public long getMtime() {
+ return mtime;
+ }
+
public boolean resourceAlreadyExisted() {
return resourceAlreadyExisted;
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
index 992b14b..3b323e1 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/StandaloneContainer.java
@@ -941,7 +941,7 @@ public class StandaloneContainer {
@Override
public MergeResourceResponse addResource(Resource resource, int creatorSubjectId)
{
- return new MergeResourceResponse(manualAddResourceCounter++,false);
+ return new MergeResourceResponse(manualAddResourceCounter++,
System.currentTimeMillis(), false);
}
@Override
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 5dd9826..1001a3a 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
@@ -19,6 +19,9 @@
package org.rhq.core.pc.inventory;
+import gnu.trove.map.TIntObjectMap;
+import gnu.trove.map.hash.TIntObjectHashMap;
+
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
@@ -45,9 +48,6 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantReadWriteLock;
-import gnu.trove.map.TIntObjectMap;
-import gnu.trove.map.hash.TIntObjectHashMap;
-
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.NotNull;
@@ -235,9 +235,8 @@ public class InventoryManager extends AgentService implements
ContainerService,
* Constructs a new instance.
* Call {@link #initialize()} once constructed.
*/
- public InventoryManager(PluginContainerConfiguration configuration,
- AgentServiceStreamRemoter streamRemoter, PluginManager pluginManager,
- EventManager eventManager) {
+ public InventoryManager(PluginContainerConfiguration configuration,
AgentServiceStreamRemoter streamRemoter,
+ PluginManager pluginManager, EventManager eventManager) {
super(DiscoveryAgentService.class, streamRemoter);
this.configuration = configuration;
if (pluginManager == null)
@@ -960,8 +959,10 @@ public class InventoryManager extends AgentService implements
ContainerService,
mergeResourceResponse = discoveryServerService.addResource(resource,
ownerSubjectId);
// Sync our local resource up with the one now in server inventory. Treat
this like a newlyCommittedResource
+ // - set mtime (same as ctime for a new resource) to ensure this does not get
picked up in an inventory sync
+ // pass, we know we're currently in sync with the server.
resource.setId(mergeResourceResponse.getResourceId());
- resource.setMtime(0); // this will indicate that this resource is
"dirty" and needs to be synced/merged later
+ resource.setMtime(mergeResourceResponse.getMtime());
Set newResources = new LinkedHashSet<Resource>();
newResources.add(resource);
postProcessNewlyCommittedResources(newResources);
diff --git
a/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
b/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
index f0c1230..dce2b4c 100644
---
a/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
+++
b/modules/plugins/netservices/src/test/java/org/rhq/plugins/netservices/itest/NetServiceComponentTest.java
@@ -100,14 +100,15 @@ public abstract class NetServiceComponentTest {
containerConfig.setPluginFinder(new FileSystemPluginFinder(pluginDir));
containerConfig.setPluginDirectory(pluginDir);
containerConfig.setInsideAgent(false);
- // netservices plugin has resources which can only be manually added so we have
to mock server integration.
+ // netservices plugin has resources which can only be manually added so we have
to mock server integration.
DiscoveryServerService discoveryServerService =
Mockito.mock(DiscoveryServerService.class);
when(discoveryServerService.addResource(any(Resource.class),
anyInt())).thenAnswer(
new Answer<MergeResourceResponse>() {
@Override
public MergeResourceResponse answer(InvocationOnMock invocation) throws
Throwable {
- return new
MergeResourceResponse(resourceIdGenerator.decrementAndGet(), false);
+ return new
MergeResourceResponse(resourceIdGenerator.decrementAndGet(), System.currentTimeMillis(),
+ false);
}
});
ServerServices serverServices = new ServerServices();
commit d9acd985470322ceb15687d5cbfd48c0809fd093
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 21 17:05:20 2014 -0500
Support postgres WITH queries
diff --git a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
index 7a0f490..292ff56 100644
--- a/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
+++ b/modules/enterprise/gui/portal-war/src/main/webapp/admin/test/sql.jsp
@@ -99,8 +99,9 @@ private StringBuffer processSQL ( Connection conn, String sql, int
index, int nu
throw e;
}
}
-
- if ( LCsql.startsWith("select") ||
+
+ if ( LCsql.startsWith("select") ||
+ LCsql.startsWith("with") ||
LCsql.startsWith("values") ) {
try {
markTime = System.currentTimeMillis();
commit b7f798ea56d2b0dac374bdc955fbc71a5b7be264
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Fri Feb 21 09:09:46 2014 -0500
remove useless and confusing annotation. Length attr is used for DDL
generation, which we don't do. And our actual length is 4000 at the
moment.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
index b340cca..b8e4757 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/measurement/MeasurementDataTrait.java
@@ -22,7 +22,6 @@
*/
package org.rhq.core.domain.measurement;
-import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
@@ -100,7 +99,6 @@ public class MeasurementDataTrait extends MeasurementData {
private static final long serialVersionUID = 1L;
- @Column(length = 255)
private String value;
/**