modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
| 14 ---
modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java
| 14 ++-
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/BundleDeploymentCriteria.java
| 10 +-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
| 8 +
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerBean.java
| 44 +++++++++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
| 12 ++
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java
| 12 ++
7 files changed, 94 insertions(+), 20 deletions(-)
New commits:
commit 2c28670eafacf818240ee8e22e696dd3a955ce3c
Merge: 546a772... 43e85fb...
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 30 16:49:40 2010 -0400
Merge branch 'gwt' into gwt-jay
commit 546a7720c20e6985dcf6a36b5c7e3fcdf7a4aa36
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 30 16:48:48 2010 -0400
More support for deployment status and group deployment status
diff --git
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java
index d248fc2..466dce1 100644
---
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java
+++
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java
@@ -30,6 +30,7 @@ import org.rhq.core.communications.command.annotation.Asynchronous;
import org.rhq.core.communications.command.annotation.LimitedConcurrency;
import org.rhq.core.communications.command.annotation.Timeout;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.content.PackageVersion;
/**
@@ -43,8 +44,6 @@ public interface BundleServerService {
@Asynchronous(guaranteedDelivery = true)
void addDeploymentHistory(int bundleDeploymentId, BundleDeploymentHistory history);
- List<PackageVersion> getAllBundleVersionPackageVersions(int bundleVersionId);
-
/**
* Requests that the server download and stream the bits for the specified package
version.
* If the package cannot be found, an exception will be thrown.
@@ -60,4 +59,15 @@ public interface BundleServerService {
@Timeout(45 * 60 * 1000L)
@LimitedConcurrency(ContentServerService.CONCURRENCY_LIMIT_CONTENT_DOWNLOAD)
long downloadPackageBits(PackageVersion packageVersion, OutputStream outputStream);
+
+ List<PackageVersion> getAllBundleVersionPackageVersions(int bundleVersionId);
+
+ /**
+ * Set the (completion) status of a deployment. If required, detailed messages
should be provided via
+ * addDeploymentHistory(). Deployments are automatically initialized to IN_PROGRESS.
+ * @param bundleDeploymentId
+ * @param status
+ */
+ @Asynchronous(guaranteedDelivery = true)
+ void setBundleDeploymentStatus(int bundleDeploymentId, BundleDeploymentStatus
status);
}
\ No newline at end of file
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 7db3060..66ad88a 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
@@ -37,6 +37,7 @@ public class BundleDeploymentCriteria extends Criteria {
private Integer filterId;
private Integer filterBundleDeployDefinitionId; // requires override
private String filterBundleDeployDefinitionName; // requires override
+ private Integer filterBundleGroupDeploymentId; // requires override
private Integer filterResourceId; // requires override
private String filterResourceName; // requires override
private BundleDeploymentStatus filterStatus;
@@ -46,10 +47,11 @@ public class BundleDeploymentCriteria extends Criteria {
private boolean fetchHistory;
public BundleDeploymentCriteria() {
- filterOverrides.put("resourceId", "resource.id = ?");
- filterOverrides.put("resourceName", "resource.name like ?");
filterOverrides.put("bundleDeployDefinitionId", "parentResource.id
= ?");
filterOverrides.put("bundleDeployDefinitionName",
"parentResource.name like ?");
+ filterOverrides.put("bundleGroupDeploymentId",
"bundleGroupDeployment.id = ?");
+ filterOverrides.put("resourceId", "resource.id = ?");
+ filterOverrides.put("resourceName", "resource.name like ?");
}
@Override
@@ -69,6 +71,10 @@ public class BundleDeploymentCriteria extends Criteria {
this.filterBundleDeployDefinitionName = filterBundleDeployDefinitionName;
}
+ public void addFilterBundleGroupDeploymentId(Integer filterBundleGroupDeploymentId)
{
+ this.filterBundleGroupDeploymentId = filterBundleGroupDeploymentId;
+ }
+
public void addFilterResourceId(Integer filterResourceId) {
this.filterResourceId = filterResourceId;
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
index 04b29a8..9602eed 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -43,6 +43,7 @@ import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.bundle.BundleVersion;
import org.rhq.core.domain.content.PackageVersion;
@@ -146,7 +147,7 @@ public class BundleManager extends AgentService implements
BundleAgentService, B
if (!result.isSuccess()) {
response.setErrorMessage(result.getErrorMessage());
}
- auditDeployment(deployment, BundleDeploymentAction.DEPLOYMENT_END,
"Success");
+ completeDeployment(deployment, BundleDeploymentStatus.SUCCESS,
"Success");
} catch (Throwable t) {
log.error("Failed to schedule bundle request: " + request, t);
response.setErrorMessage(t);
@@ -205,6 +206,11 @@ public class BundleManager extends AgentService implements
BundleAgentService, B
return packageVersionFiles;
}
+ private void completeDeployment(BundleDeployment deployment, BundleDeploymentStatus
status, String message) {
+ getBundleServerService().setBundleDeploymentStatus(deployment.getId(), status);
+ auditDeployment(deployment, BundleDeploymentAction.DEPLOYMENT_END, message);
+ }
+
private void auditDeployment(BundleDeployment deployment, BundleDeploymentAction
action, String message) {
BundleDeploymentHistory history = new BundleDeploymentHistory("Bundle
Plugin", action, message);
getBundleServerService().addDeploymentHistory(deployment.getId(), history);
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 db9c232..ec2e788 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
@@ -49,6 +49,7 @@ import org.rhq.core.domain.bundle.BundleDeployDefinition;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentAction;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleFile;
import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
@@ -71,6 +72,7 @@ import org.rhq.core.domain.resource.Resource;
import org.rhq.core.domain.resource.ResourceType;
import org.rhq.core.domain.resource.group.ResourceGroup;
import org.rhq.core.domain.util.PageList;
+import org.rhq.core.domain.util.StringUtils;
import org.rhq.core.util.NumberUtil;
import org.rhq.enterprise.server.RHQConstants;
import org.rhq.enterprise.server.agentclient.AgentClient;
@@ -155,7 +157,13 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
// of packages in the bundle's repo.
ResourceType resourceType = entityManager.find(ResourceType.class,
bundleType.getResourceType().getId());
PackageType packageType = new PackageType(name, resourceType);
+ packageType.setDescription("Package type for content of bundle " +
name);
packageType.setCategory(PackageCategory.BUNDLE);
+ packageType.setSupportsArchitecture(false);
+ packageType.setDisplayName(StringUtils.deCamelCase(name));
+ packageType.setDiscoveryInterval(-1L);
+ packageType.setCreationData(false);
+ packageType.setDeploymentConfigurationDefinition(null);
bundle.setPackageType(packageType);
log.info("Creating bundle: " + bundle);
@@ -241,6 +249,7 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
return bv;
}
+ @SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public BundleVersion createBundleVersion(Subject subject, int bundleId, String name,
String description,
String version, String recipe) throws Exception {
@@ -310,6 +319,7 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
return bundleVersion;
}
+ @SuppressWarnings("unchecked")
private String getVersion(String version, Bundle bundle) {
if (null != version && version.trim().length() > 0) {
return version;
@@ -492,6 +502,7 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
if (!response.isSuccess()) {
history = new BundleDeploymentHistory(subject.getName(),
BundleDeploymentAction.DEPLOYMENT_END, "Failure: "
+ response.getErrorMessage());
+ bundleManager.setBundleDeploymentStatus(subject, deployment.getId(),
BundleDeploymentStatus.FAILURE);
bundleManager.addBundleDeploymentHistory(subject, deployment.getId(),
history);
}
@@ -553,6 +564,37 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
return deployment;
}
+ @RequiredPermission(Permission.MANAGE_INVENTORY)
+ public BundleDeployment setBundleDeploymentStatus(Subject subject, int
bundleDeploymentId,
+ BundleDeploymentStatus status) throws Exception {
+
+ BundleDeployment deployment = entityManager.find(BundleDeployment.class,
bundleDeploymentId);
+ if (null == deployment) {
+ throw new IllegalArgumentException("Invalid bundleDeploymentId: " +
bundleDeploymentId);
+ }
+
+ deployment.setStatus(status);
+ this.entityManager.persist(deployment);
+
+ // If this is part of a group deployment then update the group status, if
necessary.
+ BundleGroupDeployment groupDeployment = deployment.getBundleGroupDeployment();
+ if ((null != groupDeployment) &&
(BundleDeploymentStatus.INPROGRESS.equals(groupDeployment.getStatus()))) {
+ if (BundleDeploymentStatus.FAILURE.equals(status)) {
+ groupDeployment.setStatus(status);
+ } else {
+ BundleDeploymentCriteria c = new BundleDeploymentCriteria();
+ c.addFilterBundleGroupDeploymentId(groupDeployment.getId());
+ c.addFilterStatus(BundleDeploymentStatus.INPROGRESS);
+ List<BundleDeployment> inProgressDeployments =
findBundleDeploymentsByCriteria(subject, c);
+ if (inProgressDeployments.isEmpty()) {
+ groupDeployment.setStatus(BundleDeploymentStatus.SUCCESS);
+ }
+ }
+ }
+
+ return deployment;
+ }
+
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public BundleGroupDeployment createBundleGroupDeployment(BundleGroupDeployment
bundleGroupDeployment)
throws Exception {
@@ -711,7 +753,7 @@ public class BundleManagerBean implements BundleManagerLocal,
BundleManagerRemot
return results;
}
- // TODO This is not adequate!!!
+ @SuppressWarnings("unchecked")
@RequiredPermission(Permission.MANAGE_INVENTORY)
public void deleteBundle(Subject subject, int bundleId) throws Exception {
Bundle bundle = this.entityManager.find(Bundle.class, bundleId);
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
index b265f0e..e55959f 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleManagerLocal.java
@@ -25,6 +25,7 @@ import javax.ejb.Local;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.bundle.BundleDeployment;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleGroupDeployment;
import org.rhq.core.domain.bundle.BundleType;
@@ -81,4 +82,15 @@ public interface BundleManagerLocal extends BundleManagerRemote {
// added here because the same method in @Remote was commented out to bypass a
WSProvide issue
Map<String, Boolean> getAllBundleVersionFilenames(Subject subject, int
bundleVersionId) throws Exception;
+ /**
+ * Called internally to set deployment status. Typically to a completion status when
deployment ends.
+ *
+ * @param subject
+ * @param bundleDeploymentId id of the deployment appending the history record
+ * @param status
+ * @return the updated BundleDeployment
+ */
+ BundleDeployment setBundleDeploymentStatus(Subject subject, int bundleDeploymentId,
BundleDeploymentStatus status)
+ throws Exception;
+
}
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java
index afda193..8350784 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java
@@ -28,6 +28,7 @@ import org.apache.commons.logging.LogFactory;
import org.rhq.core.clientapi.server.bundle.BundleServerService;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.bundle.BundleDeploymentHistory;
+import org.rhq.core.domain.bundle.BundleDeploymentStatus;
import org.rhq.core.domain.bundle.BundleFile;
import org.rhq.core.domain.content.PackageVersion;
import org.rhq.core.domain.criteria.BundleFileCriteria;
@@ -94,4 +95,15 @@ public class BundleServerServiceImpl implements BundleServerService {
throw new WrappedRemotingException(e);
}
}
+
+ public void setBundleDeploymentStatus(int bundleDeploymentId, BundleDeploymentStatus
status) {
+ try {
+ BundleManagerLocal bm = LookupUtil.getBundleManager();
+ bm.setBundleDeploymentStatus(LookupUtil.getSubjectManager().getOverlord(),
bundleDeploymentId, status);
+ } catch (Exception e) {
+ log.error("Failed to set status for deployment id: " +
bundleDeploymentId, e);
+ throw new WrappedRemotingException(e);
+ }
+ }
+
}
\ No newline at end of file
commit c171369abcd868a407b9f9c71eceb6000dc6e8d4
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Mar 30 13:58:58 2010 -0400
remove package type creation for the bundle type
diff --git
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index 26bf354..686b16b 100644
---
a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++
b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -50,7 +50,6 @@ import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.SubCategoryDescriptor;
import org.rhq.core.domain.bundle.BundleType;
-import org.rhq.core.domain.content.PackageType;
import org.rhq.core.domain.event.EventDefinition;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.resource.ClassLoaderType;
@@ -60,7 +59,6 @@ import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceCreationDataType;
import org.rhq.core.domain.resource.ResourceSubCategory;
import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.util.StringUtils;
/**
* This is a stateful class intended to hold the related metadata for a single plugin
descriptor. It is designed to be
@@ -527,18 +525,6 @@ public class PluginMetadataParser {
if (bundle != null) {
String typeName = bundle.getType();
resourceType.setBundleType(new BundleType(typeName, resourceType));
-
- // create the peer package type for the bundle type
- PackageType bundlePackageType = new PackageType();
- bundlePackageType.setName(typeName);
- bundlePackageType.setDescription("Package type for content of
bundles of type " + typeName);
- bundlePackageType.setCategory(null);
- bundlePackageType.setSupportsArchitecture(false);
- bundlePackageType.setDisplayName(StringUtils.deCamelCase(typeName));
- bundlePackageType.setDiscoveryInterval(-1L);
- bundlePackageType.setCreationData(false);
- bundlePackageType.setDeploymentConfigurationDefinition(null);
- resourceType.addPackageType(bundlePackageType);
}
} catch (InvalidPluginDescriptorException e) {