Package org.rhq.core.domain.criteria

Examples of org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria


        configurationManager.updateResourceConfiguration(overlord, resource.getId(), configuration);

        Thread.sleep(2000); // wait for the test agent to complete the request

        // at this point in time, the round trip messaging is done and we have the agent response
        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
        criteria.addFilterResourceIds(resource.getId());
        criteria.fetchConfiguration(true);
        criteria.addSortCreatedTime(PageOrdering.ASC);

        List<ResourceConfigurationUpdate> requests;

        requests = configurationManager.findResourceConfigurationUpdatesByCriteria(overlord, criteria);
View Full Code Here


        Configuration configuration3 = new Configuration();
        configuration3.put(new PropertySimple("myboolean", "TRUE"));
        configurationManager.updateResourceConfiguration(overlord, resource.getId(), configuration3);
        Thread.sleep(3000); // wait for the test agent to complete the request

        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
        criteria.addFilterResourceIds(resource.getId());
        criteria.fetchConfiguration(true);
        criteria.addSortCreatedTime(PageOrdering.ASC);
        List<ResourceConfigurationUpdate> history = configurationManager.findResourceConfigurationUpdatesByCriteria(
            overlord, criteria);
        assert history != null;
        assert history.size() == 3;

        Configuration currentConfiguration = history.get(2).getConfiguration();
        PropertySimple mybool = currentConfiguration.getSimple("myboolean");
        assert mybool != null;
        assertEquals("TRUE", mybool.getStringValue());

        // now grab one of the earlier configurations and rollback to it
        Configuration rollbackToHere = history.get(1).getConfiguration(); // the "false" one
        mybool = rollbackToHere.getSimple("myboolean");
        assert mybool != null;
        assertEquals("false", mybool.getStringValue());

        configurationManager.updateResourceConfiguration(overlord, resource.getId(), rollbackToHere);
        Thread.sleep(3000); // wait for the test agent to complete the request

        criteria = new ResourceConfigurationUpdateCriteria();
        criteria.addFilterResourceIds(resource.getId());
        criteria.fetchConfiguration(true);
        criteria.addSortCreatedTime(PageOrdering.ASC);

        history = configurationManager.findResourceConfigurationUpdatesByCriteria(overlord, criteria);
        assert history != null;
        assert history.size() == 4;
        ResourceConfigurationUpdate newConfigUpdate = history.get(3); // the last one is the new one
View Full Code Here

        configurationManager.purgeResourceConfigurationUpdate(overlord, doomedRequest.getId(), false);

        // now get the current configs/requests and
        // make sure we deleted the only one configuration that succeeded, leaving one update record
        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
        criteria.addFilterResourceIds(resource.getId());
        criteria.fetchConfiguration(true);
        criteria.addSortCreatedTime(PageOrdering.ASC);

        requests = configurationManager.findResourceConfigurationUpdatesByCriteria(overlord, criteria);

        assert requests.size() == 1;
View Full Code Here

                Thread.sleep(2000L);
            } catch (InterruptedException e) {
                // nothing
            }
            // wait for the resource config update
            ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
            criteria.addFilterId(resourceUpdate.getId());
            criteria.addFilterStartTime(System.currentTimeMillis() - (5 * 60 * 1000));
            boolean updateSuccess = waitForConfigurationUpdateToFinish(subject, criteria, 10);

            // restart the storage node and wait for it
            boolean restartSuccess = runOperationAndWaitForResult(subject, storageNodeResource, RESTART_OPERATION,
                    null, 5000, 15);
View Full Code Here

                    });
            }

            @Override
            protected ResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
                ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
                criteria
                    .addFilterGroupConfigurationUpdateId(HistoryGroupResourceConfigurationMembers.this.groupUpdateId);
                criteria.fetchResource(true);
                return criteria;
            }
View Full Code Here

        }

        return new StreamingOutput() {
            @Override
            public void write(OutputStream stream) throws IOException, WebApplicationException {
                final ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
                criteria.fetchConfiguration(true);
                criteria.addSortCreatedTime(ASC);

                CriteriaQueryExecutor<ResourceConfigurationUpdate, ResourceConfigurationUpdateCriteria> queryExecutor =
                        new CriteriaQueryExecutor<ResourceConfigurationUpdate, ResourceConfigurationUpdateCriteria>() {
                            @Override
                            public PageList<ResourceConfigurationUpdate> execute(ResourceConfigurationUpdateCriteria criteria) {
View Full Code Here

    }

    @Override
    public void renderView(ViewPath viewPath) {

        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();

        int updateId = viewPath.getCurrentAsInt();
        criteria.addFilterId(updateId);

        criteria.fetchConfiguration(true);
        criteria.fetchResource(true);
        criteria.fetchGroupConfigurationUpdate(true);

        GWTServiceLookup.getConfigurationService().findResourceConfigurationUpdatesByCriteria(criteria,
            new AsyncCallback<PageList<ResourceConfigurationUpdate>>() {
                public void onFailure(Throwable caught) {
                    CoreGUI.getErrorHandler().handleError(MSG.view_configurationHistoryDetails_error_loadFailure(),
View Full Code Here

                    if (!results.isEmpty()) {
                        resourceComposite = results.get(0);
                        //instantiate view

                        PageControl lastFive = new PageControl(0, 5);
                        ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
                        criteria.setPageControl(lastFive);
                        //TODO: spinder: move this up into the pageControl.
                        criteria.addSortStatus(PageOrdering.DESC);
                        criteria.addFilterResourceIds(resourceId);

                        resourceHistoryTable = new ResourceConfigurationHistoryCriteriaView(resourceComposite
                            .getResourcePermission().isConfigureWrite(), resourceId);
                    } else {
                        resourceHistoryTable = new ResourceConfigurationHistoryCriteriaView(resourceComposite
View Full Code Here

        }

        @Override
        protected ResourceConfigurationUpdateCriteria getFetchCriteria(final DSRequest request) {
            //initialize criteria
            ResourceConfigurationUpdateCriteria criteria = new ResourceConfigurationUpdateCriteria();
            criteria.addFilterResourceIds(resourceId);

            //initialize to only five for quick queries.
            PageControl pageControl = new PageControl(0, Integer.valueOf(Constant.RESULT_COUNT_DEFAULT));
            //customize query with latest configuration selections

            //retrieve previous settings from portlet config
            if (portletConfig != null) {
                //            //result sort order
                //            PropertySimple property = portletConfig.getSimple(Constant.RESULT_SORT_ORDER);
                //            if (property != null) {
                //                String currentSetting = property.getStringValue();
                //                if (currentSetting.trim().isEmpty() || currentSetting.equalsIgnoreCase(PageOrdering.DESC.name())) {
                //                    criteria.addSortStatus(PageOrdering.DESC);
                //                } else {
                //                    criteria.addSortStatus(PageOrdering.ASC);
                //                }
                //            }
                //result timeframe if enabled
                PropertySimple property = portletConfig.getSimple(Constant.METRIC_RANGE_ENABLE);
                if (null != property && Boolean.valueOf(property.getBooleanValue())) {//then proceed setting

                    //detect type of widget[Simple|Advanced]
                    boolean isAdvanced = Boolean.valueOf(portletConfig.getSimpleValue(
                        Constant.METRIC_RANGE_BEGIN_END_FLAG, Constant.METRIC_RANGE_BEGIN_END_FLAG_DEFAULT));
                    if (isAdvanced) {
                        //Advanced time settings
                        String currentSetting = portletConfig.getSimpleValue(Constant.METRIC_RANGE,
                            Constant.METRIC_RANGE_DEFAULT);
                        String[] range = currentSetting.split(",");
                        if (range.length == 2) {
                            criteria.addFilterStartTime(Long.valueOf(range[0]));
                            criteria.addFilterEndTime(Long.valueOf(range[1]));
                        }
                    } else {
                        //Simple time settings
                        property = portletConfig.getSimple(Constant.METRIC_RANGE_LASTN);
                        if (property != null) {
                            Integer lastN = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_LASTN,
                                Constant.METRIC_RANGE_LASTN_DEFAULT));
                            Integer units = Integer.valueOf(portletConfig.getSimpleValue(Constant.METRIC_RANGE_UNIT,
                                Constant.METRIC_RANGE_UNIT_DEFAULT));
                            ArrayList<Long> beginEnd = MeasurementUtility.calculateTimeFrame(lastN, units);
                            criteria.addFilterStartTime(Long.valueOf(beginEnd.get(0)));
                            criteria.addFilterEndTime(Long.valueOf(beginEnd.get(1)));
                        }
                    }
                }

                //result count
                String currentSetting = portletConfig.getSimpleValue(Constant.RESULT_COUNT,
                    Constant.RESULT_COUNT_DEFAULT);
                if (currentSetting.trim().isEmpty()) {
                    pageControl.setPageSize(Integer.valueOf(Constant.RESULT_COUNT_DEFAULT));
                } else {
                    pageControl.setPageSize(Integer.valueOf(currentSetting));
                }
                criteria.setPageControl(pageControl);

                //detect operation status filter
                String configUpdateStatus = portletConfig.getSimpleValue(Constant.CONFIG_UPDATE_STATUS,
                    Constant.CONFIG_UPDATE_STATUS_DEFAULT);
                String[] parsedValues = configUpdateStatus.trim().split(",");
                if (configUpdateStatus.trim().isEmpty()
                    || parsedValues.length == ConfigurationUpdateStatus.values().length) {
                    //all operation stati assumed
                } else {
                    ConfigurationUpdateStatus[] updateStatus = new ConfigurationUpdateStatus[parsedValues.length];
                    int indx = 0;
                    for (String priority : parsedValues) {
                        ConfigurationUpdateStatus s = ConfigurationUpdateStatus.valueOf(priority);
                        updateStatus[indx++] = s;
                    }
                    criteria.addFilterStatuses(updateStatus);
                }
            }
            return criteria;
        }
View Full Code Here

            });
    }

    @Override
    protected ResourceConfigurationUpdateCriteria createFetchCriteria() {
        return new ResourceConfigurationUpdateCriteria();
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.criteria.ResourceConfigurationUpdateCriteria

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.