[rhq] Branch 'bug/902406' - modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit f658f9542ecb953249b7ba5859abfb6b72221057
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 31 18:22:05 2013 -0500
make a array copy of the IDs
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 29ca007..59a669e 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
@@ -2889,7 +2889,7 @@ public class InventoryManager extends AgentService implements ContainerService,
int end = (BATCH_SIZE < size) ? BATCH_SIZE : size;
List<Integer> resourceIdBatch = resourceIdList.subList(0, end);
- Integer[] resourceIdArray = new Integer[resourceIdBatch.size()];
+ Integer[] resourceIdArray = resourceIdBatch.toArray(new Integer[resourceIdBatch.size()]);
// Advance our progress and possibly help GC. This will remove the processed resources from the backing list
resourceIdBatch.clear();
10 years, 10 months
[rhq] Branch 'bug/902406' - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java | 2
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 9 ++-
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java | 24 ++++++----
3 files changed, 23 insertions(+), 12 deletions(-)
New commits:
commit 270606f4c7613efd3444df25f872230dc1c55de2
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Thu Jan 31 17:38:48 2013 -0500
Hopefully get more speed in mergeUnknownResource logic by
making a single criteria query for a batch of ids, and passing
Integers by array.
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
index 04915ae..1e2ee9f 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
@@ -101,7 +101,7 @@ public interface DiscoveryServerService {
* @return a list of resources in the same order as the passed in ids, with the latest data
*/
@LimitedConcurrency(CONCURRENCY_LIMIT_INVENTORY_SYNC)
- List<Resource> getResourcesAsList(List<Integer> resourceIds);
+ List<Resource> getResourcesAsList(Integer... resourceIds);
/**
* Set the specified resource enabled or disabled. The call has no effect if the resource is already
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 3b31fee..29ca007 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
@@ -2889,10 +2889,13 @@ public class InventoryManager extends AgentService implements ContainerService,
int end = (BATCH_SIZE < size) ? BATCH_SIZE : size;
List<Integer> resourceIdBatch = resourceIdList.subList(0, end);
- ArrayList<Integer> serializableResourceIdBatch = new ArrayList<Integer>(resourceIdBatch);
- resourceIdBatch.clear(); // advance progress now - this helps GC by clearing now
+ Integer[] resourceIdArray = new Integer[resourceIdBatch.size()];
+
+ // Advance our progress and possibly help GC. This will remove the processed resources from the backing list
+ resourceIdBatch.clear();
+
List<Resource> resourceBatch = configuration.getServerServices().getDiscoveryServerService()
- .getResourcesAsList(serializableResourceIdBatch);
+ .getResourcesAsList(resourceIdArray);
// add the newly fetched resources to the end of our master list
for (Resource r : resourceBatch) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
index fe03746..4a269da 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
@@ -35,6 +35,7 @@ import org.rhq.core.clientapi.server.discovery.InventoryReport;
import org.rhq.core.clientapi.server.discovery.StaleTypeException;
import org.rhq.core.domain.auth.Subject;
import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.criteria.ResourceCriteria;
import org.rhq.core.domain.discovery.AvailabilityReport;
import org.rhq.core.domain.discovery.MergeResourceResponse;
import org.rhq.core.domain.discovery.ResourceSyncInfo;
@@ -171,16 +172,23 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
}
@Override
- public List<Resource> getResourcesAsList(List<Integer> resourceIds) {
+ public List<Resource> getResourcesAsList(Integer... resourceIds) {
long start = System.currentTimeMillis();
+
+ ResourceCriteria criteria = new ResourceCriteria();
+ criteria.addFilterIds(resourceIds);
+ criteria.addFilterInventoryStatus(null); // get them all and remove some later
+ criteria.clearPaging();
+
ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
- List<Resource> result = new ArrayList<Resource>(resourceIds.size());
- for (Integer resourceId : resourceIds) {
- //TODO: This can probably be one call to resource criteria fetch
- Resource resource = resourceManager.getResourceTree(resourceId, false);
- if (isVisibleInInventory(resource)) {
- resource = convertToPojoResource(resource, false);
- result.add(resource);
+ Subject overlord = LookupUtil.getSubjectManager().getOverlord();
+ List<Resource> resources = resourceManager.findResourcesByCriteria(overlord, criteria);
+ List<Resource> result = new ArrayList<Resource>(resources.size());
+
+ for (Resource r : resources) {
+ if (isVisibleInInventory(r)) {
+ Resource resourcePojo = convertToPojoResource(r, false);
+ result.add(resourcePojo);
}
}
if (log.isDebugEnabled()) {
10 years, 10 months
[rhq] Branch 'bug/902406' - modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 3a537379ea8ff95145c876d3ba9ca7c771489c92
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 31 17:14:12 2013 -0500
opp.. no need to pass this param
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 822dd38..3b31fee 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
@@ -2910,7 +2910,7 @@ public class InventoryManager extends AgentService implements ContainerService,
StopWatch stopWatch = new StopWatch();
- result = syncInfoTreeToResourceTree(syncInfo, null, resourceMap);
+ result = syncInfoTreeToResourceTree(syncInfo, resourceMap);
//TODO if (log.isDebugEnabled()) {
log.info("syncInfoTreeToResourceTree time=[" + stopWatch + "]");
10 years, 10 months
[rhq] Branch 'bug/902406' - modules/core
by mazz
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 12 ++++------
1 file changed, 5 insertions(+), 7 deletions(-)
New commits:
commit 3c0c3d47c86c3e1aa0b4ee7617924ba660f88ec7
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Thu Jan 31 17:11:32 2013 -0500
* make sure to send proper object over the wire
* don't need parent param
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 780eaf8..822dd38 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
@@ -2889,11 +2889,10 @@ public class InventoryManager extends AgentService implements ContainerService,
int end = (BATCH_SIZE < size) ? BATCH_SIZE : size;
List<Integer> resourceIdBatch = resourceIdList.subList(0, end);
+ ArrayList<Integer> serializableResourceIdBatch = new ArrayList<Integer>(resourceIdBatch);
+ resourceIdBatch.clear(); // advance progress now - this helps GC by clearing now
List<Resource> resourceBatch = configuration.getServerServices().getDiscoveryServerService()
- .getResourcesAsList(resourceIdBatch);
-
- // Advance our progress and possibly help GC. This will remove the processed resources from the backing list
- resourceIdBatch.clear();
+ .getResourcesAsList(serializableResourceIdBatch);
// add the newly fetched resources to the end of our master list
for (Resource r : resourceBatch) {
@@ -2920,8 +2919,7 @@ public class InventoryManager extends AgentService implements ContainerService,
return result;
}
- private Resource syncInfoTreeToResourceTree(ResourceSyncInfo syncInfo, Resource parentResource,
- Map<Integer, Resource> resourceMap) {
+ private Resource syncInfoTreeToResourceTree(ResourceSyncInfo syncInfo, Map<Integer, Resource> resourceMap) {
Resource result = resourceMap.get(syncInfo.getId());
if (null == result || null == syncInfo.getChildSyncInfos()) {
@@ -2929,7 +2927,7 @@ public class InventoryManager extends AgentService implements ContainerService,
}
for (ResourceSyncInfo child : syncInfo.getChildSyncInfos()) {
- Resource childResource = syncInfoTreeToResourceTree(child, result, resourceMap);
+ Resource childResource = syncInfoTreeToResourceTree(child, resourceMap);
if (null != childResource) {
result.addChildResource(childResource);
}
10 years, 10 months
[rhq] Branch 'bug/902406' - modules/core modules/enterprise
by Jay Shaughnessy
modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java | 17 -
modules/core/plugin-container/src/main/java/org/rhq/core/pc/inventory/InventoryManager.java | 149 +++++++---
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java | 32 +-
3 files changed, 161 insertions(+), 37 deletions(-)
New commits:
commit 4d3f721141b42c1e1ac6eed3a93124f51fbae3e6
Author: Jay Shaughnessy <jshaughn(a)jshaughn.csb>
Date: Thu Jan 31 15:43:28 2013 -0500
Try to batch unknown resource merge in the inventory sync to
help with large inventories and an agent start --purgeData
- also fix issues with server service annotations
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
index 6b2fba6..04915ae 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/discovery/DiscoveryServerService.java
@@ -22,6 +22,7 @@
*/
package org.rhq.core.clientapi.server.discovery;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -63,8 +64,8 @@ public interface DiscoveryServerService {
@LimitedConcurrency(CONCURRENCY_LIMIT_INVENTORY_REPORT)
@Timeout(0L)
// should be something like 1000L * 60 * 30 but until we can be assured we never take longer, disable timeout
- ResourceSyncInfo mergeInventoryReport(InventoryReport inventoryReport)
- throws InvalidInventoryReportException, StaleTypeException;
+ ResourceSyncInfo mergeInventoryReport(InventoryReport inventoryReport) throws InvalidInventoryReportException,
+ StaleTypeException;
/**
* Merges a new availability report from the agent into the server. This updates the availability statuses of known
@@ -90,9 +91,19 @@ public interface DiscoveryServerService {
* @param includeDescendants
* @return a tree of resources with the latest data
*/
+ @LimitedConcurrency(CONCURRENCY_LIMIT_INVENTORY_SYNC)
Set<Resource> getResources(Set<Integer> resourceIds, boolean includeDescendants);
/**
+ * Returns the Resources with the given id's. The children are not set.
+ *
+ * @param resourceIds
+ * @return a list of resources in the same order as the passed in ids, with the latest data
+ */
+ @LimitedConcurrency(CONCURRENCY_LIMIT_INVENTORY_SYNC)
+ List<Resource> getResourcesAsList(List<Integer> resourceIds);
+
+ /**
* Set the specified resource enabled or disabled. The call has no effect if the resource is already
* in the desired state.
*
@@ -158,7 +169,7 @@ public interface DiscoveryServerService {
* @return details on what resources have been upgraded with what data.
*/
Set<ResourceUpgradeResponse> upgradeResources(Set<ResourceUpgradeRequest> upgradeRequests);
-
+
/**
* Gives the server a chance to apply any necessary post-processing that's needed for newly committed resources
* that have been successfully synchronized on the agent.
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 eaca661..780eaf8 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
@@ -120,6 +120,7 @@ import org.rhq.core.pluginapi.upgrade.ResourceUpgradeContext;
import org.rhq.core.pluginapi.upgrade.ResourceUpgradeFacet;
import org.rhq.core.system.SystemInfo;
import org.rhq.core.system.SystemInfoFactory;
+import org.rhq.core.util.StopWatch;
import org.rhq.core.util.exception.ThrowableUtil;
import org.rhq.core.util.exception.WrappedRemotingException;
@@ -851,8 +852,7 @@ public class InventoryManager extends AgentService implements ContainerService,
// it will be accessible and editable by the user. Report the start exception at the end.
handleInvalidPluginConfigurationResourceError(resource, t);
throw new PluginContainerException("The resource [" + resource
- + "] has been added but could not be started. Verify the supplied configuration values: ",
- t);
+ + "] has been added but could not be started. Verify the supplied configuration values: ", t);
}
}
@@ -1108,7 +1108,7 @@ public class InventoryManager extends AgentService implements ContainerService,
log.info("Syncing local inventory with Server inventory...");
long startTime = System.currentTimeMillis();
Set<Resource> syncedResources = new LinkedHashSet<Resource>();
- Set<Integer> unknownResourceIds = new LinkedHashSet<Integer>();
+ Set<ResourceSyncInfo> unknownResourceSyncInfos = new LinkedHashSet<ResourceSyncInfo>();
Set<Integer> modifiedResourceIds = new LinkedHashSet<Integer>();
Set<Integer> deletedResourceIds = new LinkedHashSet<Integer>();
Set<Resource> newlyCommittedResources = new LinkedHashSet<Resource>();
@@ -1124,16 +1124,16 @@ public class InventoryManager extends AgentService implements ContainerService,
}
log.debug("Processing Server sync info...");
- processSyncInfo(syncInfo, syncedResources, unknownResourceIds, modifiedResourceIds, deletedResourceIds,
- newlyCommittedResources);
+ processSyncInfo(syncInfo, syncedResources, unknownResourceSyncInfos, modifiedResourceIds,
+ deletedResourceIds, newlyCommittedResources);
if (log.isDebugEnabled()) {
log.debug(String.format("DONE Processing sync info - took [%d] ms - synced [%d] Resources "
+ "- found [%d] unknown Resources and [%d] modified Resources.",
- (System.currentTimeMillis() - startTime), syncedResources.size(), unknownResourceIds.size(),
+ (System.currentTimeMillis() - startTime), syncedResources.size(), unknownResourceSyncInfos.size(),
modifiedResourceIds.size()));
}
- mergeUnknownResources(unknownResourceIds);
+ mergeUnknownResources(unknownResourceSyncInfos);
mergeModifiedResources(modifiedResourceIds);
if (!partialInventory) {
purgeObsoleteResources(allServerSideUuids);
@@ -1157,7 +1157,7 @@ public class InventoryManager extends AgentService implements ContainerService,
// the upgrade phase. Not to mention the fact that no thread pools are initialized yet by the
// time the upgrade kicks in..
if (!isResourceUpgradeActive()
- && (!syncedResources.isEmpty() || !unknownResourceIds.isEmpty() || !modifiedResourceIds.isEmpty())) {
+ && (!syncedResources.isEmpty() || !unknownResourceSyncInfos.isEmpty() || !modifiedResourceIds.isEmpty())) {
performAvailabilityChecks(true);
this.inventoryThreadPoolExecutor.schedule((Callable<? extends Object>) this.serviceScanExecutor,
configuration.getChildResourceDiscoveryDelay(), TimeUnit.SECONDS);
@@ -1610,8 +1610,9 @@ public class InventoryManager extends AgentService implements ContainerService,
* @throws PluginContainerException
* @return true the resource has been successfully prepared and can be started. False if the resource should not be started.
*/
- private boolean prepareResourceForActivation(Resource resource, @NotNull ResourceContainer container,
- boolean forceReinitialization) throws InvalidPluginConfigurationException, PluginContainerException {
+ private boolean prepareResourceForActivation(Resource resource, @NotNull
+ ResourceContainer container, boolean forceReinitialization) throws InvalidPluginConfigurationException,
+ PluginContainerException {
if (resourceUpgradeDelegate.hasUpgradeFailed(resource)) {
if (log.isTraceEnabled()) {
@@ -1753,8 +1754,9 @@ public class InventoryManager extends AgentService implements ContainerService,
* plugin configuration
* @throws PluginContainerException for all other errors
*/
- public void activateResource(Resource resource, @NotNull ResourceContainer container, boolean updatedPluginConfig)
- throws InvalidPluginConfigurationException, PluginContainerException {
+ public void activateResource(Resource resource, @NotNull
+ ResourceContainer container, boolean updatedPluginConfig) throws InvalidPluginConfigurationException,
+ PluginContainerException {
if (resourceUpgradeDelegate.hasUpgradeFailed(resource)) {
if (log.isTraceEnabled()) {
@@ -1831,8 +1833,7 @@ public class InventoryManager extends AgentService implements ContainerService,
getOperationContext(resource), // for operation manager access
getContentContext(resource), // for content manager access
getAvailabilityContext(resource, this.availabilityCollectors), // for components that want to perform async avail checking
- getInventoryContext(resource),
- this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do
+ getInventoryContext(resource), this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do
}
public <T extends ResourceComponent<?>> ResourceUpgradeContext<T> createResourceUpgradeContext(Resource resource,
@@ -1851,8 +1852,7 @@ public class InventoryManager extends AgentService implements ContainerService,
getOperationContext(resource), // for operation manager access
getContentContext(resource), // for content manager access
getAvailabilityContext(resource, this.availabilityCollectors), // for components that want avail manager access
- getInventoryContext(resource),
- this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do
+ getInventoryContext(resource), this.configuration.getPluginContainerDeployment()); // helps components make determinations of what to do
}
/**
@@ -2753,8 +2753,8 @@ public class InventoryManager extends AgentService implements ContainerService,
}
private void processSyncInfo(ResourceSyncInfo syncInfo, Set<Resource> syncedResources,
- Set<Integer> unknownResourceIds, Set<Integer> modifiedResourceIds, Set<Integer> deletedResourceIds,
- Set<Resource> newlyCommittedResources) {
+ Set<ResourceSyncInfo> unknownResourceSyncInfos, Set<Integer> modifiedResourceIds,
+ Set<Integer> deletedResourceIds, Set<Resource> newlyCommittedResources) {
if (InventoryStatus.DELETED == syncInfo.getInventoryStatus()) {
// A previously deleted resource still being reported by the server. Support for this option can
// be removed if the server is ever modified to not report deleted resources. It is happening currently
@@ -2765,7 +2765,7 @@ public class InventoryManager extends AgentService implements ContainerService,
ResourceContainer container = this.resourceContainers.get(syncInfo.getUuid());
if (container == null) {
// Either a manually added Resource or just something we haven't discovered.
- unknownResourceIds.add(syncInfo.getId());
+ unknownResourceSyncInfos.add(syncInfo);
log.info("Got unknown resource: " + syncInfo.getId());
} else {
Resource resource = container.getResource();
@@ -2811,7 +2811,7 @@ public class InventoryManager extends AgentService implements ContainerService,
// Recurse...
for (ResourceSyncInfo childSyncInfo : syncInfo.getChildSyncInfos()) {
- processSyncInfo(childSyncInfo, syncedResources, unknownResourceIds, modifiedResourceIds,
+ processSyncInfo(childSyncInfo, syncedResources, unknownResourceSyncInfos, modifiedResourceIds,
deletedResourceIds, newlyCommittedResources);
}
}
@@ -2831,18 +2831,16 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
- private void mergeUnknownResources(Set<Integer> unknownResourceIds) {
- if (log.isDebugEnabled()) {
- log.debug("Merging [" + unknownResourceIds.size()
- + "] unknown Resources and their descendants into local inventory...");
- }
+ private void mergeUnknownResources(Set<ResourceSyncInfo> unknownResourceSyncInfos) {
+ //TODO if (log.isDebugEnabled()) {
+ log.info("Merging [" + unknownResourceSyncInfos.size()
+ + "] unknown Resources and their descendants into local inventory...");
+ //}
- if (!unknownResourceIds.isEmpty()) {
+ if (!unknownResourceSyncInfos.isEmpty()) {
PluginMetadataManager pmm = this.pluginManager.getMetadataManager();
- Set<Resource> unknownResources = configuration.getServerServices().getDiscoveryServerService()
- .getResources(unknownResourceIds, true);
-
+ Set<Resource> unknownResources = getResourcesFromSyncInfos(unknownResourceSyncInfos);
Set<Integer> toBeIgnored = new HashSet<Integer>();
for (Resource unknownResource : unknownResources) {
@@ -2860,11 +2858,102 @@ public class InventoryManager extends AgentService implements ContainerService,
}
}
- unknownResourceIds.removeAll(toBeIgnored);
+ unknownResourceSyncInfos.removeAll(toBeIgnored);
}
return;
}
+ private Set<Resource> getResourcesFromSyncInfos(Set<ResourceSyncInfo> syncInfos) {
+
+ Set<Resource> result = new HashSet<Resource>(syncInfos.size());
+
+ for (ResourceSyncInfo syncInfo : syncInfos) {
+ Resource resource = getResourceFromSyncInfo(syncInfo);
+ result.add(resource);
+ }
+
+ return result;
+ }
+
+ static final int BATCH_SIZE = 500;
+
+ private Resource getResourceFromSyncInfo(ResourceSyncInfo syncInfo) {
+ Resource result;
+
+ List<Integer> resourceIdList = treeToBreadthFirstList(syncInfo);
+
+ Map<Integer, Resource> resourceMap = new HashMap<Integer, Resource>(resourceIdList.size());
+
+ while (!resourceIdList.isEmpty()) {
+ int size = resourceIdList.size();
+ int end = (BATCH_SIZE < size) ? BATCH_SIZE : size;
+
+ List<Integer> resourceIdBatch = resourceIdList.subList(0, end);
+ List<Resource> resourceBatch = configuration.getServerServices().getDiscoveryServerService()
+ .getResourcesAsList(resourceIdBatch);
+
+ // Advance our progress and possibly help GC. This will remove the processed resources from the backing list
+ resourceIdBatch.clear();
+
+ // add the newly fetched resources to the end of our master list
+ for (Resource r : resourceBatch) {
+ resourceMap.put(r.getId(), r);
+ }
+
+ // Again, help the GC
+ resourceBatch.clear();
+ }
+
+ if (resourceIdList.size() != resourceMap.size()) {
+ log.warn("Expected [" + resourceIdList.size() + "] but found [" + resourceMap.size()
+ + "] resources when fetching from server");
+ }
+
+ StopWatch stopWatch = new StopWatch();
+
+ result = syncInfoTreeToResourceTree(syncInfo, null, resourceMap);
+
+ //TODO if (log.isDebugEnabled()) {
+ log.info("syncInfoTreeToResourceTree time=[" + stopWatch + "]");
+ //}
+
+ return result;
+ }
+
+ private Resource syncInfoTreeToResourceTree(ResourceSyncInfo syncInfo, Resource parentResource,
+ Map<Integer, Resource> resourceMap) {
+ Resource result = resourceMap.get(syncInfo.getId());
+
+ if (null == result || null == syncInfo.getChildSyncInfos()) {
+ return result;
+ }
+
+ for (ResourceSyncInfo child : syncInfo.getChildSyncInfos()) {
+ Resource childResource = syncInfoTreeToResourceTree(child, result, resourceMap);
+ if (null != childResource) {
+ result.addChildResource(childResource);
+ }
+ }
+
+ return result;
+ }
+
+ private List<Integer> treeToBreadthFirstList(ResourceSyncInfo syncInfo) {
+ List<Integer> result = new ArrayList<Integer>();
+
+ LinkedList<ResourceSyncInfo> queue = new LinkedList<ResourceSyncInfo>();
+ queue.add(syncInfo);
+ while (!queue.isEmpty()) {
+ ResourceSyncInfo node = queue.remove();
+ result.add(node.getId());
+ for (ResourceSyncInfo child : node.getChildSyncInfos()) {
+ queue.add(child);
+ }
+ }
+
+ return result;
+ }
+
// private void print(Resource resourceTreeNode, int level) {
// StringBuilder builder = new StringBuilder();
// for (int i = 0; i < level; i++) {
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
index ebc0cd1..fe03746 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/discovery/DiscoveryServerServiceImpl.java
@@ -18,7 +18,9 @@
*/
package org.rhq.enterprise.server.discovery;
+import java.util.ArrayList;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -130,10 +132,12 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
long elapsed = (System.currentTimeMillis() - start);
if (elapsed > 20000L) {
- log.warn("Performance: processed " + reportToString + " - needFull=[" + !ok + "] in (" + elapsed + ")ms");
+ log.warn("Performance: processed " + reportToString + " - needFull=[" + !ok + "] in (" + elapsed
+ + ")ms");
} else {
if (log.isDebugEnabled()) {
- log.debug("Performance: processed " + reportToString + " - needFull=[" + !ok + "] in (" + elapsed + ")ms");
+ log.debug("Performance: processed " + reportToString + " - needFull=[" + !ok + "] in (" + elapsed
+ + ")ms");
}
}
@@ -167,6 +171,26 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
}
@Override
+ public List<Resource> getResourcesAsList(List<Integer> resourceIds) {
+ long start = System.currentTimeMillis();
+ ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
+ List<Resource> result = new ArrayList<Resource>(resourceIds.size());
+ for (Integer resourceId : resourceIds) {
+ //TODO: This can probably be one call to resource criteria fetch
+ Resource resource = resourceManager.getResourceTree(resourceId, false);
+ if (isVisibleInInventory(resource)) {
+ resource = convertToPojoResource(resource, false);
+ result.add(resource);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Performance: get ResourcesAsList [" + resourceIds + "], timing ("
+ + (System.currentTimeMillis() - start) + ")ms");
+ }
+ return result;
+ }
+
+ @Override
public Map<Integer, InventoryStatus> getInventoryStatus(int rootResourceId, boolean descendents) {
long start = System.currentTimeMillis();
ResourceManagerLocal resourceManager = LookupUtil.getResourceManager();
@@ -244,8 +268,8 @@ public class DiscoveryServerServiceImpl implements DiscoveryServerService {
}
private static boolean isVisibleInInventory(Resource resource) {
- return resource.getInventoryStatus() != InventoryStatus.DELETED &&
- resource.getInventoryStatus() != InventoryStatus.UNINVENTORIED;
+ return resource.getInventoryStatus() != InventoryStatus.DELETED
+ && resource.getInventoryStatus() != InventoryStatus.UNINVENTORIED;
}
@Override
10 years, 10 months
[rhq] Changes to 'bug/902406'
by Jay Shaughnessy
New branch 'bug/902406' available with the following commits:
commit 791f8148611c4e6d830dd3cfdfe55b8d7489e86b
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 30 17:30:11 2013 -0500
[BZ 902406] i still think this doesn't work. but its close. we now merge unknown resources and their children breadth first. however, i think we need children specified in some resources when we don't. need to take a closer look and test
commit f16bf96fe7491e146fe9117aaf623d551f4b1102
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 30 16:08:21 2013 -0500
[BZ 902406] this doesn't work. the getResources call with "false" means we don't get the children, which we need to recursively process the tree
commit abda69f79c03cfe996c2bb3d959647a6829d43b8
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Jan 30 16:07:44 2013 -0500
[BZ 902406] we need to have a limit on getResources since it is a major part of the inventory sync and can be expensive
10 years, 10 months
[rhq] modules/enterprise
by lkrejci
modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js | 46 ++++-----
modules/enterprise/remoting/cli/src/main/samples/modules/jbossas.js | 48 ++++------
2 files changed, 43 insertions(+), 51 deletions(-)
New commits:
commit f702a1b942ad22abac485108d19bbeeaedf5371d
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Thu Jan 31 18:42:48 2013 +0100
[BZ 906495] - The JBoss AS specific bundle functions should work again.
diff --git a/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js b/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js
index a8afc26..9739cb1 100644
--- a/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js
+++ b/modules/enterprise/remoting/cli/src/main/samples/deploy-to-and-restart-JBAS.js
@@ -60,7 +60,7 @@ function createAppAndRestartJBAS(bundleZipFile, deploymentConfiguration, groupNa
var bundleVersion = createBundleVersion(bundleZipFile);
var destination = BundleManager.createBundleDestination(bundleVersion.bundle.id, destinationName, destinationDescription, baseDirName, deployDir, group.id);
- var deployment = deployBundle(bundleVersion, destination, deploymentConfiguration, null);
+ var deployment = deployBundle(destination, bundleVersion, deploymentConfiguration, null, false);
if (deployment.status != BundleDeploymentStatus.SUCCESS) {
throw "Deployment wasn't successful: " + deployment;
@@ -71,17 +71,7 @@ function createAppAndRestartJBAS(bundleZipFile, deploymentConfiguration, groupNa
return deployment;
};
- if (targetResourceType.plugin == "JBossAS" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS4);
- } else if (targetResourceType.plugin == "JBossAS5" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS5);
- } else if (targetResourceType.plugin == "jboss-as-7" &&
- (targetResourceType.name == "JBossAS7-Standalone" ||
- targetResourceType.name == "JBossAS-Managed")) {
- return deployFn(_restartAS7);
- }
-
- throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
+ return deployFn(_restartFunction(targetResourceType));
}
/**
@@ -132,7 +122,7 @@ function updateAppAndRestartJBAS(bundleZipFile, jbasDestination, deploymentConfi
var deployFn = function(restartFn) {
var bundleVersion = createBundleVersion(bundleZipFile);
- var deployment = deployBundle(bundleVersion, destination, deploymentConfiguration, null);
+ var deployment = deployBundle(destination, bundleVersion, deploymentConfiguration, null, false);
if (deployment.status != BundleDeploymentStatus.SUCCESS) {
throw "Deployment wasn't successful: " + deployment;
@@ -143,17 +133,23 @@ function updateAppAndRestartJBAS(bundleZipFile, jbasDestination, deploymentConfi
return deployment;
};
- if (targetResourceType.plugin == "JBossAS" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS4);
- } else if (targetResourceType.plugin == "JBossAS5" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS5);
- } else if (targetResourceType.plugin == "jboss-as-7" &&
- (targetResourceType.name == "JBossAS7-Standalone" ||
- targetResourceType.name == "JBossAS-Managed")) {
- return deployFn(_restartAS7);
- }
+ return deployFn(_restartFunction(targetResourceType));
+}
- throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
+/** Helper method to return a correct restart function for given resource type of JBoss AS */
+function _restartFunction(asResourceType) {
+ if (asResourceType.plugin == "JBossAS" && asResourceType.name == "JBossAS Server") {
+ return _restartAS4;
+ } else if (asResourceType.plugin == "JBossAS5" && asResourceType.name == "JBossAS Server") {
+ return _restartAS5;
+ } else if (asResourceType.plugin == "JBossAS7" &&
+ (asResourceType.name == "JBossAS7 Standalone Server" ||
+ asResourceType.name == "Managed Server")) {
+
+ return _restartAS7);
+ } else {
+ throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
+ }
}
function _loadGroupMembers(group) {
@@ -236,8 +232,8 @@ function _restartAS5(group) {
}
function _restartAS7(group) {
- var shutdownOp = group.resourceType.name == "JBossAS7-Standalone" ? "shutdown" : "server:stop";
- var startOp = group.resourceType.name == "JBossAS7-Standalone" ? "start" : "server:start";
+ var shutdownOp = group.resourceType.name == "JBossAS7 Standalone Server" ? "shutdown" : "stop";
+ var startOp = "start";
_runOperationSequentially(group, shutdownOp, new Configuration);
_runOperationSequentially(group, startOp, new Configuration);
diff --git a/modules/enterprise/remoting/cli/src/main/samples/modules/jbossas.js b/modules/enterprise/remoting/cli/src/main/samples/modules/jbossas.js
index 6369cc1..8122a2b 100644
--- a/modules/enterprise/remoting/cli/src/main/samples/modules/jbossas.js
+++ b/modules/enterprise/remoting/cli/src/main/samples/modules/jbossas.js
@@ -52,7 +52,7 @@ exports.createAppAndRestart = function(bundleZipFile, deploymentConfiguration, g
var bundleVersion = bundles.createBundleVersion(bundleZipFile);
var destination = BundleManager.createBundleDestination(bundleVersion.bundle.id, destinationName, destinationDescription, baseDirName, deployDir, group.id);
- var deployment = bundles.deployBundle(bundleVersion, destination, deploymentConfiguration, null);
+ var deployment = bundles.deployBundle(destination, bundleVersion, deploymentConfiguration, null, false);
if (deployment.status != BundleDeploymentStatus.SUCCESS) {
throw "Deployment wasn't successful: " + deployment;
@@ -63,17 +63,7 @@ exports.createAppAndRestart = function(bundleZipFile, deploymentConfiguration, g
return deployment;
};
- if (targetResourceType.plugin == "JBossAS" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS4);
- } else if (targetResourceType.plugin == "JBossAS5" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS5);
- } else if (targetResourceType.plugin == "jboss-as-7" &&
- (targetResourceType.name == "JBossAS7-Standalone" ||
- targetResourceType.name == "JBossAS-Managed")) {
- return deployFn(_restartAS7);
- }
-
- throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
+ return deployFn(_restartFunction(targetResourceType));
}
/**
@@ -124,7 +114,7 @@ exports.updateAppAndRestart = function(bundleZipFile, jbasDestination, deploymen
var deployFn = function(restartFn) {
var bundleVersion = bundles.createBundleVersion(bundleZipFile);
- var deployment = bundles.deployBundle(bundleVersion, destination, deploymentConfiguration, null);
+ var deployment = bundles.deployBundle(destination, bundleVersion, deploymentConfiguration, null, false);
if (deployment.status != BundleDeploymentStatus.SUCCESS) {
throw "Deployment wasn't successful: " + deployment;
@@ -135,17 +125,7 @@ exports.updateAppAndRestart = function(bundleZipFile, jbasDestination, deploymen
return deployment;
};
- if (targetResourceType.plugin == "JBossAS" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS4);
- } else if (targetResourceType.plugin == "JBossAS5" && targetResourceType.name == "JBossAS Server") {
- return deployFn(_restartAS5);
- } else if (targetResourceType.plugin == "jboss-as-7" &&
- (targetResourceType.name == "JBossAS7-Standalone" ||
- targetResourceType.name == "JBossAS-Managed")) {
- return deployFn(_restartAS7);
- }
-
- throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
+ return deployFn(_restartFunction(targetResourceType));
}
/**
@@ -339,6 +319,22 @@ exports.as7.copyDeployments = function(sourceAS7, targetAS7) {
}
}
+/** Helper method to return a correct restart function for given resource type of JBoss AS */
+function _restartFunction(asResourceType) {
+ if (asResourceType.plugin == "JBossAS" && asResourceType.name == "JBossAS Server") {
+ return _restartAS4;
+ } else if (asResourceType.plugin == "JBossAS5" && asResourceType.name == "JBossAS Server") {
+ return _restartAS5;
+ } else if (asResourceType.plugin == "JBossAS7" &&
+ (asResourceType.name == "JBossAS7 Standalone Server" ||
+ asResourceType.name == "Managed Server")) {
+
+ return _restartAS7);
+ } else {
+ throw "The resource group the destination targets doesn't seem to be a JBoss AS server group.";
+ }
+}
+
function _getConfigName(as7PluginConfig) {
var argsValue = as7PluginConfig.getSimpleValue('startScriptArgs', '');
@@ -803,8 +799,8 @@ function _restartAS5(group) {
}
function _restartAS7(group) {
- var shutdownOp = group.resourceType.name == "JBossAS7-Standalone" ? "shutdown" : "server:stop";
- var startOp = group.resourceType.name == "JBossAS7-Standalone" ? "start" : "server:start";
+ var shutdownOp = group.resourceType.name == "JBossAS7 Standalone Server" ? "shutdown" : "stop";
+ var startOp = "start";
_runOperationSequentially(group, shutdownOp, new Configuration);
_runOperationSequentially(group, startOp, new Configuration);
10 years, 10 months