[rhq] Branch 'stefan/inventorycontext' - modules/core modules/plugins
snegrea
snegrea at fedoraproject.org
Tue Aug 7 02:07:12 UTC 2012
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/InventoryContext.java | 38 +++++++++-
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java | 4 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryContextImpl.java | 13 ++-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 29 +++++--
modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java | 2
5 files changed, 70 insertions(+), 16 deletions(-)
New commits:
commit 2b17808e9bff072776c7ecada992d33c34203155
Author: Stefan Negrea <snegrea at redhat.com>
Date: Mon Aug 6 21:07:00 2012 -0500
[BZ 828329] The inventory context has now a deferred and a blocking method for requesting discovery. Also included are various other updates based on community feedback.
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/InventoryContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/InventoryContext.java
index c2ca7e3..5ae11eb 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/InventoryContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/InventoryContext.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -20,6 +20,8 @@
package org.rhq.core.pluginapi.inventory;
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
+
/**
* @author Stefan Negrea
*
@@ -27,8 +29,38 @@ package org.rhq.core.pluginapi.inventory;
public interface InventoryContext {
/**
- * This method starts the discovery process for children of the resource.
+ * This method requests a deferred service discovery process for children of the resource. It request the discovery
+ * process and returns immediately without waiting for results. The discovery process inventories all discovered
+ * resources, so no further action is required.
+ *
+ * This method should be used by resources following an action (outside of create/delete children) that results
+ * in having additional children discoverable. A good example is an operation execution that enables extra functionality
+ * on managed resource which in turn translates into having additional children available for management.
+ *
+ * Note: All resources are discovered by the regular platform level discovery process that runs every 24 hours. This method allows
+ * a resource to request a discovery for child resources to be run immediately, rather than wait for the scheduled platform
+ * discovery.
+ */
+ public void requestDeferredChildResourcesDiscovery();
+
+
+ /**
+ * This method requests a service discovery process for children of the resource. It schedules the discovery
+ * process and returns the results of the discovery. The discovery process inventories all discovered
+ * resources, so no further action is required.
+ *
+ * This method should be used by resources following an action (outside of create/delete children) that results
+ * in having additional children discoverable. A good example is an operation execution that enables extra functionality
+ * on the managed resource which in turn translates into having additional children available for management. This method returns
+ * the results of the discovery to allow for additional processing, however all discovered resources are already
+ * committed to the inventory before returning the results.
+ *
+ * Note: All resources are discovered by the regular platform level discovery process that runs every 24 hours. This method allows
+ * a resource to request a discovery for child resources to be run immediately, rather than wait for the scheduled platform
+ * discovery.
+ *
+ * @return discovered child resources
*/
- public void discoverChildResources();
+ public InventoryReport requestChildResourcesDiscovery();
}
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
index af2e541..76ccf39 100644
--- a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/inventory/ResourceContext.java
@@ -507,10 +507,10 @@ public class ResourceContext<T extends ResourceComponent<?>> {
}
/**
- * Returns an {@link InventoryContext} that allows the plugin to access the run a defferred discovery functionality provided by the
+ * Returns an {@link InventoryContext} that allows the plugin to access inventory related functionality provided by the
* plugin container.
*
- * @return the inventoryContext
+ * @return the inventory context
*/
public InventoryContext getInventoryContext() {
return inventoryContext;
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryContextImpl.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryContextImpl.java
index b3ce099..b14792d 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryContextImpl.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryContextImpl.java
@@ -1,6 +1,6 @@
/*
* RHQ Management Platform
- * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, 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.
*
@@ -20,6 +20,7 @@
package org.rhq.core.pc.inventory;
+import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.domain.resource.Resource;
import org.rhq.core.pc.PluginContainer;
import org.rhq.core.pluginapi.inventory.InventoryContext;
@@ -43,7 +44,15 @@ public class InventoryContextImpl implements InventoryContext {
* @see org.rhq.core.pluginapi.inventory.InventoryContext#discoverChildResources()
*/
@Override
- public void discoverChildResources() {
+ public void requestDeferredChildResourcesDiscovery() {
PluginContainer.getInstance().getInventoryManager().executeServiceScanDeferred(resource);
}
+
+ /* (non-Javadoc)
+ * @see org.rhq.core.pluginapi.inventory.InventoryContext#requestChildResourcesDiscovery()
+ */
+ @Override
+ public InventoryReport requestChildResourcesDiscovery() {
+ return PluginContainer.getInstance().getInventoryManager().executeServiceScanImmediately(resource);
+ }
}
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 2010ef1..b3f7fa9 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
@@ -576,14 +576,27 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
+ @NotNull
+ public InventoryReport executeServiceScanImmediately(Resource resource) {
+ try {
+ RuntimeDiscoveryExecutor discoveryExecutor = new RuntimeDiscoveryExecutor(this, this.configuration,
+ resource);
+ return inventoryThreadPoolExecutor.submit((Callable<InventoryReport>) discoveryExecutor).get();
+ } catch (InterruptedException e) {
+ throw new RuntimeException("Service scan execution was interrupted", e);
+ } catch (ExecutionException e) {
+ // Should never happen, reports are always generated, even if they're just to report the error
+ throw new RuntimeException("Unexpected exception", e);
+ }
+ }
+
public void executeServiceScanDeferred() {
inventoryThreadPoolExecutor.submit((Callable<InventoryReport>) this.serviceScanExecutor);
}
public void executeServiceScanDeferred(Resource resource) {
- RuntimeDiscoveryExecutor runtimeDiscoveryExecutor = new RuntimeDiscoveryExecutor(this, this.configuration,
- resource);
- inventoryThreadPoolExecutor.submit((Callable<InventoryReport>) runtimeDiscoveryExecutor);
+ RuntimeDiscoveryExecutor discoveryExecutor = new RuntimeDiscoveryExecutor(this, this.configuration, resource);
+ inventoryThreadPoolExecutor.submit((Callable<InventoryReport>) discoveryExecutor);
}
/** this will NOT send a availability report up to the server! */
@@ -1311,13 +1324,13 @@ public class InventoryManager extends AgentService implements ContainerService,
return getContainerChildren(parentResource, getResourceContainer(parentResource));
}
- /**
+ /**
* Get the parent resource's children, ensuring we use the resource container version of the resource, because
* the container's resource is guaranteed to be up to date.
- *
+ *
* @param parentResource
* @param parentContainer
- * @return the children, empty if parentContainer is null or there are no children. not null.
+ * @return the children, empty if parentContainer is null or there are no children. not null.
* @return the children, may be empty, not null.
*/
public Set<Resource> getContainerChildren(Resource parentResource, ResourceContainer container) {
@@ -1862,7 +1875,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return this.platform;
}
} else {
- // don't use container children here, the caller is providing the desired resources
+ // don't use container children here, the caller is providing the desired resources
for (Resource child : parent.getChildResources()) {
if (child != null && matches(resource, child)) {
return child;
@@ -2385,7 +2398,7 @@ public class InventoryManager extends AgentService implements ContainerService,
/**
* The resource upgrade should only occur during the {@link #initialize()} method and should be
* switched off at all other times.
- *
+ *
* @return true if resource upgrade is currently active, false otherwise
*/
public boolean isResourceUpgradeActive() {
diff --git a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
index 37fac0e..9bc01f2 100644
--- a/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
+++ b/modules/plugins/jboss-as-7/src/main/java/org/rhq/modules/plugins/jbossas7/BaseServerComponent.java
@@ -540,7 +540,7 @@ public abstract class BaseServerComponent<T extends ResourceComponent<?>> extend
+ " server with key [" + context.getResourceKey() + "].");
context.getAvailabilityContext().requestAvailabilityCheck();
- context.getInventoryContext().discoverChildResources();
+ context.getInventoryContext().requestDeferredChildResourcesDiscovery();
return result;
}
More information about the rhq-commits
mailing list