}
chartTitle = parentGroup.getName();
Log.info("group name: " + parentGroup.getName() + ", size: " + parentGroup.getExplicitResources().size());
// setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully)
final CountDownLatch countDownLatch = CountDownLatch.create(childResources.size(), new Command() {
@Override
/**
* Do this only after ALL of the metric queries for each resource
*/
public void execute() {
if (parentGroup.getExplicitResources().size() != measurementForEachResource.size()) {
Log.warn("Number of graphs doesn't match number of resources");
Log.warn("# of child resources: " + parentGroup.getExplicitResources().size());
Log.warn("# of charted graphs: " + measurementForEachResource.size());
}
drawGraph();
}
});
if (!childResources.isEmpty()) {
// resourceType will be the same for all autogroup children so get first
Resource childResource = childResources.iterator().next();
ResourceTypeRepository.Cache.getInstance().getResourceTypes(
childResource.getResourceType().getId(),
EnumSet.of(ResourceTypeRepository.MetadataType.measurements),
new ResourceTypeRepository.TypeLoadedCallback() {
@Override
public void onTypesLoaded(final ResourceType type) {
for (MeasurementDefinition def : type.getMetricDefinitions()) {
// only need the one selected measurement
if (def.getId() == getDefinitionId()) {
setDefinition(def);
}
}
for (final Resource childResource : childResources) {
Log.debug("Adding child composite: " + childResource.getName()
+ childResource.getId());
GWTServiceLookup.getMeasurementDataService().findDataForResource(
childResource.getId(), new int[]{getDefinitionId()},
buttonBarDateTimeRangeEditor.getStartTime(),
buttonBarDateTimeRangeEditor.getEndTime(), 60,
new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() {
@Override
public void onFailure(Throwable caught) {
CoreGUI.getErrorHandler().handleError(
MSG.view_resource_monitor_graphs_loadFailed(), caught);
countDownLatch.countDown();
}
@Override
public void onSuccess(
List<List<MeasurementDataNumericHighLowComposite>> measurements) {
addMeasurementForEachResource(childResource.getName(),
childResource.getId(), measurements.get(0));
countDownLatch.countDown();
}
});
}
}
});