Package org.rhq.coregui.client.util.async

Examples of org.rhq.coregui.client.util.async.CountDownLatch


     */
    public void setMetricRangePreferences(MetricRangePreferences prefs, boolean allowRefresh, Command callback) {
        AsyncCallback<Subject> persistCallback = null;
        if (null != callback) {
            // there are either 2 or 3 setPreference calls depending on prefs.explicitBeginEnd
            final CountDownLatch latch = CountDownLatch.create(prefs.explicitBeginEnd ? 2 : 3, callback);
            persistCallback = new AsyncCallback<Subject>() {
                @Override
                public void onFailure(Throwable arg0) {
                    latch.countDown();
                }

                @Override
                public void onSuccess(Subject arg0) {
                    latch.countDown();
                }
            };
        }
        userPrefs.setPreference(PREF_METRIC_RANGE_BEGIN_END_FLAG, String.valueOf(prefs.explicitBeginEnd), allowRefresh, persistCallback);
        if (prefs.explicitBeginEnd) {
View Full Code Here


                    int i = 0;
                    for (MeasurementSchedule measurementSchedule : measurementSchedules) {
                        scheduleIds[i++] = measurementSchedule.getId();
                    }

                    final CountDownLatch countDownLatch = CountDownLatch.create(2, new Command() {

                        @Override
                        public void execute() {
                            response.setData(buildRecords(metricDisplaySummaries));
                            processResponse(request.getRequestId(), response);

                            new Timer() {

                                @Override
                                public void run() {
                                    BrowserUtility.graphSparkLines();
                                }
                            }.schedule(150);
                            Log.debug("Finished CountdownLatch for metrics loaded: " + metricsDataList.size());
                        }
                    });

                    retrieveResourceMetrics(resourceId, countDownLatch);

                    GWTServiceLookup.getMeasurementChartsService().getMetricDisplaySummariesForResource(resourceId,
                            scheduleIds, measurementUserPrefs.getMetricRangePreferences().begin,
                            measurementUserPrefs.getMetricRangePreferences().end,
                            new AsyncCallback<ArrayList<MetricDisplaySummary>>() {
                                @Override
                                public void onSuccess(ArrayList<MetricDisplaySummary> metricDisplaySummaries) {
                                    setMetricDisplaySummaries(metricDisplaySummaries);
                                    countDownLatch.countDown();
                                }

                                @Override
                                public void onFailure(Throwable caught) {
                                    CoreGUI.getErrorHandler().handleError("Cannot load metrics", caught);
                                    countDownLatch.countDown();
                                }
                            }

                    );
                }
View Full Code Here

                        }

                        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();
                                                            }
                                                        });
                                            }
                                        }
                                    });
View Full Code Here

    @Override
    protected void executeFetch(final DSRequest request, final DSResponse response, final Criteria unused) {

        // This latch is the last thing that gets executed after we have executed the
        // 1 query
        final CountDownLatch countDownLatch = CountDownLatch.create(1, new Command() {

            @Override
            public void execute() {

                // NOTE: this runs after the queryMetricDisplaySummaries is complete
View Full Code Here

    @Override
    protected void init(final boolean isReadOnly) {
        if (isNewRecord()) {

            final CountDownLatch latch = CountDownLatch.create(getOperationExampleId() == null ? 1 : 2, new Command() {
                @Override
                public void execute() {
                    GroupOperationScheduleDetailsView.super.init(isReadOnly);
                }
            });
View Full Code Here

            if (cnt == 0) {
                return;
            }

            CountDownLatch latch = CountDownLatch.create(cnt, new Command() {
                @Override
                public void execute() {
                    CoreGUI.showBusy(false);
                    markForRedraw();
View Full Code Here

    @Override
    protected void init(final boolean isReadOnly) {
        if (isNewRecord() && getOperationExampleId() != null) {

            final CountDownLatch latch = CountDownLatch.create(1, new Command() {
                @Override
                public void execute() {
                    ResourceOperationScheduleDetailsView.super.init(isReadOnly);
                }
            });
View Full Code Here

            measDefIdArray[i] = measurementDefinitions.get(i).getId();
        }

        // setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully)
        // we know there are exactly 2 resources
        final CountDownLatch countDownLatch = CountDownLatch.create(NUM_ASYNC_CALLS, new Command() {
            @Override
            /**
             * Satisfied only after ALL of the metric queries AND availability have completed
             */
            public void execute() {
View Full Code Here

            long start = adjustTimeToStartOfDay(startDate).getTime();
            long end = adjustTimeToEndOfDay(endDate).getTime();

            final List<Object> fullList = new ArrayList<Object>();

            final CountDownLatch latch = CountDownLatch.create(2, new Command() {
                @Override
                public void execute() {
                    processResults(request, response, fullList);
                }
            });

            GWTServiceLookup.getResourceService().findCreateChildResourceHistory(
                resourceComposite.getResource().getId(), start, end, PageControl.getUnlimitedInstance(),
                new AsyncCallback<PageList<CreateResourceHistory>>() {
                    @Override
                    public void onSuccess(final PageList<CreateResourceHistory> createList) {
                        fullList.addAll(createList);
                        latch.countDown();
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError("Failed to load child create history", caught);
                        latch.countDown();
                    }
                });

            GWTServiceLookup.getResourceService().findDeleteChildResourceHistory(
                resourceComposite.getResource().getId(), start, end, PageControl.getUnlimitedInstance(),
                new AsyncCallback<PageList<DeleteResourceHistory>>() {
                    @Override
                    public void onSuccess(final PageList<DeleteResourceHistory> deleteList) {
                        fullList.addAll(deleteList);
                        latch.countDown();
                    }

                    @Override
                    public void onFailure(Throwable caught) {
                        CoreGUI.getErrorHandler().handleError("Failed to load child delete history", caught);
                        latch.countDown();
                    }
                });
        }
View Full Code Here

        //display container
        final VLayout column = new VLayout();
        column.setHeight(10);//pack

        final CountDownLatch latch = CountDownLatch.create(2, new Command() {
            @Override
            public void execute() {
                if (enabledSchedules.isEmpty() || !renderChart) {
                    DynamicForm row = getEmptyDataForm();
                    column.addMember(row);
View Full Code Here

TOP

Related Classes of org.rhq.coregui.client.util.async.CountDownLatch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.