modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
| 31 +++----
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
| 10 --
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
| 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
| 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/ConfirmationStep.java
| 43 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
| 13 +--
6 files changed, 63 insertions(+), 37 deletions(-)
New commits:
commit 976c5fc6ed0e7e5354ea6a890caafa58b3f1c7bc
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Thu May 5 13:45:09 2011 -0400
[BZ 702390 - Large number of BundleDeployments for a single Bundle causes fetch
serialization issues]
Remove self-referring entity association for
BundleDeployment.replacedBundleDeployment. This prevents eager loading of
the entire deployment chain when fetching a BundleDeployment, and in turn
avoids issues with Hibernate class scrubbing when remote fetching deployments.
Instead of using the entity as the field member, just use the ID.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
index fc0c72c..dcf6c27 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -68,14 +68,14 @@ import org.rhq.core.domain.tagging.Tag;
+ "SELECT bd FROM BundleDeployment bd "),
@NamedQuery(name = BundleDeployment.QUERY_UPDATE_FOR_DESTINATION_REMOVE, query =
"" //
+ "UPDATE BundleDeployment bd " //
- + " SET bd.replacedBundleDeployment = NULL " //
- + " WHERE bd.replacedBundleDeployment.id IN " //
+ + " SET bd.replacedBundleDeploymentId = NULL " //
+ + " WHERE bd.replacedBundleDeploymentId IN " //
+ " ( SELECT innerbd.id FROM BundleDeployment innerbd " //
+ " WHERE innerbd.destination.id = :destinationId ) "),
@NamedQuery(name = BundleDeployment.QUERY_UPDATE_FOR_VERSION_REMOVE, query =
"" //
+ "UPDATE BundleDeployment bd " //
- + " SET bd.replacedBundleDeployment = NULL " //
- + " WHERE bd.replacedBundleDeployment.id IN " //
+ + " SET bd.replacedBundleDeploymentId = NULL " //
+ + " WHERE bd.replacedBundleDeploymentId IN " //
+ " ( SELECT innerbd.id FROM BundleDeployment innerbd " //
+ " WHERE innerbd.bundleVersion.id = :bundleVersionId ) ") })
@SequenceGenerator(name = "SEQ", sequenceName =
"RHQ_BUNDLE_DEPLOYMENT_ID_SEQ")
@@ -118,20 +118,23 @@ public class BundleDeployment implements Serializable {
@Column(name = "MTIME")
private Long mtime = System.currentTimeMillis();
- @JoinColumn(name = "REPLACED_BUNDLE_DEPLOYMENT_ID", referencedColumnName =
"ID", nullable = true)
- @OneToOne(fetch = FetchType.LAZY, optional = true)
- private BundleDeployment replacedBundleDeployment;
+ // This is not a join column on purpose. Since it is nullable the OneToOne
association would be forced to EAGER
+ // fetch. That leads to basically fetching every BundleDeployment every time, in a
deeply recursive way if you
+ // have a lot deployments.
+ @Column(name = "REPLACED_BUNDLE_DEPLOYMENT_ID", nullable = true)
+ private Integer replacedBundleDeploymentId;
+ // note - eager fetch, can not lazy fetch an optional OneToOne
@JoinColumn(name = "CONFIG_ID", referencedColumnName = "ID",
nullable = true)
- @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = true)
+ @OneToOne(cascade = CascadeType.ALL, optional = true)
private Configuration configuration;
@JoinColumn(name = "BUNDLE_VERSION_ID", referencedColumnName =
"ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private BundleVersion bundleVersion;
@JoinColumn(name = "BUNDLE_DESTINATION_ID", referencedColumnName =
"ID", nullable = false)
- @ManyToOne(fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY, optional = false)
private BundleDestination destination;
@OneToMany(mappedBy = "bundleDeployment", fetch = FetchType.LAZY, cascade =
CascadeType.ALL)
@@ -284,12 +287,12 @@ public class BundleDeployment implements Serializable {
/**
* @return The previously "live" BundleDeployment.
*/
- public BundleDeployment getReplacedBundleDeployment() {
- return replacedBundleDeployment;
+ public Integer getReplacedBundleDeploymentId() {
+ return replacedBundleDeploymentId;
}
- public void setReplacedBundleDeployment(BundleDeployment replacedBundleDeployment) {
- this.replacedBundleDeployment = replacedBundleDeployment;
+ public void setReplacedBundleDeploymentId(Integer replacedBundleDeploymentId) {
+ this.replacedBundleDeploymentId = replacedBundleDeploymentId;
}
public Configuration getConfiguration() {
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
index 3ad25b8..aa437e3 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
@@ -49,9 +49,7 @@ public class BundleDeploymentCriteria extends TaggedCriteria {
private String filterSubjectName;
private boolean fetchBundleVersion;
- private boolean fetchConfiguration;
private boolean fetchDestination;
- private boolean fetchReplacedBundleDeployment;
private boolean fetchResourceDeployments;
public BundleDeploymentCriteria() {
@@ -110,18 +108,10 @@ public class BundleDeploymentCriteria extends TaggedCriteria {
this.fetchBundleVersion = fetchBundleVersion;
}
- public void fetchConfiguration(boolean fetchConfiguration) {
- this.fetchConfiguration = fetchConfiguration;
- }
-
public void fetchDestination(boolean fetchDestination) {
this.fetchDestination = fetchDestination;
}
- public void fetchReplacedBundleDeployment(boolean fetchReplacedBundleDeployment) {
- this.fetchReplacedBundleDeployment = fetchReplacedBundleDeployment;
- }
-
public void fetchResourceDeployments(boolean fetchResourceDeployments) {
this.fetchResourceDeployments = fetchResourceDeployments;
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
index e1367e8..b13df74 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deploy/SelectBundleVersionStep.java
@@ -143,7 +143,6 @@ public class SelectBundleVersionStep extends AbstractWizardStep {
criteria.addFilterDestinationId(wizard.getDestination().getId());
criteria.addFilterIsLive(true);
criteria.fetchBundleVersion(true);
- criteria.fetchConfiguration(true);
bundleServer.findBundleDeploymentsByCriteria(criteria, //
new AsyncCallback<PageList<BundleDeployment>>() {
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
index e220cfc..73ea70c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/deployment/BundleDeploymentView.java
@@ -328,6 +328,7 @@ public class BundleDeploymentView extends LocatableVLayout implements
Bookmarkab
return tagEditor;
}
+ @SuppressWarnings("unchecked")
private Table addMemberDeploymentsTable() {
Table table = new Table(extendLocatorId("Deployments"),
MSG.view_bundle_deploy_deploymentPlatforms());
@@ -420,7 +421,6 @@ public class BundleDeploymentView extends LocatableVLayout implements
Bookmarkab
BundleDeploymentCriteria criteria = new BundleDeploymentCriteria();
criteria.addFilterId(bundleDeploymentId);
criteria.fetchBundleVersion(true);
- criteria.fetchConfiguration(true);
criteria.fetchResourceDeployments(true);
criteria.fetchDestination(true);
criteria.fetchTags(true);
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/ConfirmationStep.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/ConfirmationStep.java
index 3d298c2..00007cb 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/ConfirmationStep.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/bundle/revert/ConfirmationStep.java
@@ -69,13 +69,14 @@ public class ConfirmationStep extends AbstractWizardStep {
}
layout.setMembersMargin(10);
+ // Get the Live Deployment
BundleDeploymentCriteria c = new BundleDeploymentCriteria();
c.addFilterDestinationId(this.wizard.getDestination().getId());
c.addFilterIsLive(true);
- c.fetchReplacedBundleDeployment(true);
c.fetchBundleVersion(true);
bundleServer.findBundleDeploymentsByCriteria(c, //
new AsyncCallback<PageList<BundleDeployment>>() {
+
public void onSuccess(PageList<BundleDeployment>
liveDeployments) {
if (1 != liveDeployments.size()) {
nextPage = false;
@@ -86,9 +87,11 @@ public class ConfirmationStep extends AbstractWizardStep {
CoreGUI.getMessageCenter().notify(
new Message(messageConcise, message,
Message.Severity.Warning));
}
+
wizard.setLiveDeployment(liveDeployments.get(0));
-
wizard.setPreviousDeployment(wizard.getLiveDeployment().getReplacedBundleDeployment());
- if (null == wizard.getPreviousDeployment()) {
+ Integer replacedBundleDeploymentId =
wizard.getLiveDeployment().getReplacedBundleDeploymentId();
+
+ if (null == replacedBundleDeploymentId) {
nextPage = false;
String messageConcise = MSG
.view_bundle_revertWizard_confirmStep_noPriorDeployment_concise();
@@ -99,7 +102,39 @@ public class ConfirmationStep extends AbstractWizardStep {
new Message(messageConcise, message,
Message.Severity.Warning));
}
- setLayout();
+ // Get the Replaced Deployment (the one we want to revert to_
+ BundleDeploymentCriteria c = new BundleDeploymentCriteria();
+ c.addFilterId(replacedBundleDeploymentId);
+ bundleServer.findBundleDeploymentsByCriteria(c, //
+ new AsyncCallback<PageList<BundleDeployment>>()
{
+
+ public void onSuccess(PageList<BundleDeployment>
replacedBundleDeployments) {
+ if (1 != replacedBundleDeployments.size()) {
+ nextPage = false;
+ String messageConcise = MSG
+
.view_bundle_revertWizard_confirmStep_noPriorDeployment_concise();
+ String message =
MSG.view_bundle_revertWizard_confirmStep_noPriorDeployment(
+ wizard.getLiveDeployment().toString(),
wizard.getDestination().toString());
+ wizard.getView().showMessage(message);
+ CoreGUI.getMessageCenter().notify(
+ new Message(messageConcise, message,
Message.Severity.Warning));
+ }
+
+
wizard.setPreviousDeployment(replacedBundleDeployments.get(0));
+ setLayout();
+ }
+
+ public void onFailure(Throwable caught) {
+ nextPage = false;
+ String messageConcise = MSG
+
.view_bundle_revertWizard_confirmStep_noPriorDeployment_concise();
+ String message =
MSG.view_bundle_revertWizard_confirmStep_noPriorDeployment(wizard
+ .getLiveDeployment().toString(),
wizard.getDestination().toString());
+ wizard.getView().showMessage(message);
+ CoreGUI.getMessageCenter().notify(
+ new Message(messageConcise, message,
Message.Severity.Warning));
+ }
+ });
}
public void onFailure(Throwable caught) {
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
index d0ddc8f..7a6e08a 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
@@ -926,7 +926,6 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
BundleDeploymentCriteria c = new BundleDeploymentCriteria();
c.addFilterDestinationId(bundleDestinationId);
c.addFilterIsLive(true);
- c.fetchReplacedBundleDeployment(true);
c.fetchDestination(true);
List<BundleDeployment> liveDeployments =
bundleManager.findBundleDeploymentsByCriteria(subject, c);
if (1 != liveDeployments.size()) {
@@ -934,15 +933,15 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
+ "]");
}
BundleDeployment liveDeployment = liveDeployments.get(0);
- BundleDeployment prevDeployment = liveDeployment.getReplacedBundleDeployment();
- if (null == prevDeployment) {
+ Integer prevDeploymentId = liveDeployment.getReplacedBundleDeploymentId();
+ if (null == prevDeploymentId) {
throw new IllegalArgumentException(
"Live deployment ["
+ liveDeployment
+ "] can not be reverted. The Live deployment is either an
initial deployment or a reverted deployment for destinationId ["
+ bundleDestinationId + "]");
}
- prevDeployment = entityManager.find(BundleDeployment.class,
prevDeployment.getId());
+ BundleDeployment prevDeployment = entityManager.find(BundleDeployment.class,
prevDeploymentId);
if (null == prevDeployment) {
throw new IllegalArgumentException("Live deployment [" +
liveDeployment
+ "] can not be reverted. There is no prior deployment for
destinationId [" + bundleDestinationId + "]");
@@ -999,9 +998,9 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
for (BundleDeployment d : currentDeployments) {
if (d.isLive()) {
d.setLive(false);
- // you can not revert a revert, it does not logically replace
anything, it is
+ // you can not revert a revert, it does not logically replace
anything
if (!isRevert) {
- newDeployment.setReplacedBundleDeployment(d);
+ newDeployment.setReplacedBundleDeploymentId(d.getId());
}
break;
}
@@ -1096,7 +1095,6 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
BundleDeploymentCriteria bdc = new BundleDeploymentCriteria();
bdc.addFilterId(resourceDeployment.getBundleDeployment().getId());
bdc.fetchBundleVersion(true);
- bdc.fetchConfiguration(true);
bdc.fetchDestination(true);
BundleDeployment deployment =
bundleManager.findBundleDeploymentsByCriteria(subject, bdc).get(0);
@@ -1471,6 +1469,7 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
// to break the FK dependency with nulls.
Query q =
entityManager.createNamedQuery(BundleDeployment.QUERY_UPDATE_FOR_VERSION_REMOVE);
q.setParameter("bundleVersionId", bundleVersionId);
+ @SuppressWarnings("unused")
int rowsUpdated = q.executeUpdate();
entityManager.flush();