Package org.rhq.enterprise.server.measurement

Examples of org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal


    public void testImportWithDefaultConfiguration() throws Exception {
        setup(true);

        try {
            SystemManagerLocal systemManager = LookupUtil.getSystemManager();
            MeasurementDefinitionManagerLocal measurementDefinitionManager = LookupUtil
                .getMeasurementDefinitionManager();

            SystemSettings beforeSystemSettings = systemManager.getUnmaskedSystemSettings(false);
            MeasurementDefinitionCriteria criteria = new MeasurementDefinitionCriteria();
            criteria.setPageControl(PageControl.getUnlimitedInstance());
            criteria.fetchResourceType(true);

            List<MeasurementDefinition> beforeMeasurementDefinitions = measurementDefinitionManager
                .findMeasurementDefinitionsByCriteria(freshUser(), criteria);

            synchronizationManager.importAllSubsystems(freshUser(), export.getExportFile(), null);

            //this is to work around BZ 735810
            systemManager.loadSystemConfigurationCache();

            SystemSettings afterSystemSettings = systemManager.getUnmaskedSystemSettings(false);
            List<MeasurementDefinition> afterMeasurementDefinitions = measurementDefinitionManager
                .findMeasurementDefinitionsByCriteria(freshUser(), criteria);

            assertEquals("System settings unexpectedly differ", beforeSystemSettings, afterSystemSettings);

            //make sure we don't fail on simple order differences, which are not important here..
View Full Code Here


            SystemManagerLocal systemManager = LookupUtil.getSystemManager();
            SystemSettings settings = systemManager.getUnmaskedSystemSettings(false);

            assertEquals(settings.get(SystemSetting.BASE_URL), "http://testing.domain:7080");

            MeasurementDefinitionManagerLocal measurementDefinitionManager = LookupUtil
                .getMeasurementDefinitionManager();
            MeasurementDefinitionCriteria crit = new MeasurementDefinitionCriteria();
            crit.addFilterResourceTypeName(RESOURCE_TYPE_NAME);
            crit.addFilterName(METRIC_NAME);
            MeasurementDefinition mdef = measurementDefinitionManager.findMeasurementDefinitionsByCriteria(freshUser(),
                crit).get(0);

            assertEquals("The " + METRIC_NAME + " metric should have been updated with default interval of 30s",
                Long.valueOf(30000), new Long(mdef.getDefaultInterval()));
View Full Code Here

            SystemManagerLocal systemManager = LookupUtil.getSystemManager();
            SystemSettings settings = systemManager.getUnmaskedSystemSettings(false);

            String originalBaseUrl = settings.get(SystemSetting.BASE_URL);

            MeasurementDefinitionManagerLocal measurementDefinitionManager = LookupUtil
                .getMeasurementDefinitionManager();
            MeasurementDefinitionCriteria crit = new MeasurementDefinitionCriteria();
            crit.addFilterResourceTypeName(RESOURCE_TYPE_NAME);
            crit.addFilterName(METRIC_NAME);
            MeasurementDefinition distroNameDef = measurementDefinitionManager.findMeasurementDefinitionsByCriteria(
                freshUser(), crit).get(0);

            long originalInterval = distroNameDef.getDefaultInterval();

            //now modify the default configuration in the export file
            String exportXML = getExportData();

            exportXML = updateSystemSettingsImportConfiguration(exportXML);
            exportXML = updateMetricTemplatesImportConfiguration(exportXML);

            InputStream exportData = createCompressedStream(exportXML);

            //let's just use the default configs so that we don't apply the changes suggested in
            //the changed default configs created above
            ImportConfiguration systemSettingsConfiguration = new ImportConfiguration(
                SystemSettingsSynchronizer.class.getName(), new SystemSettingsSynchronizer().getImporter()
                    .getImportConfigurationDefinition().getDefaultTemplate().createConfiguration());
            ImportConfiguration metricTemplatesConfiguration = new ImportConfiguration(
                MetricTemplateSynchronizer.class.getName(), new MetricTemplateSynchronizer().getImporter()
                    .getImportConfigurationDefinition().getDefaultTemplate().createConfiguration());

            try {
                synchronizationManager.importAllSubsystems(freshUser(), exportData,
                    Arrays.asList(systemSettingsConfiguration, metricTemplatesConfiguration));
            } finally {
                exportData.close();
            }

            //now check that we import using the manually create configurations, not the inlined ones
            settings = systemManager.getUnmaskedSystemSettings(false);

            assertEquals(settings.get(SystemSetting.BASE_URL), originalBaseUrl);

            measurementDefinitionManager = LookupUtil.getMeasurementDefinitionManager();
            distroNameDef = measurementDefinitionManager.findMeasurementDefinitionsByCriteria(freshUser(), crit).get(0);

            //the definition should have been updated by the data from the export file
            assertEquals("The " + METRIC_NAME + " metric shouldn't have changed its default interval", 30000,
                distroNameDef.getDefaultInterval());
View Full Code Here

public class MetricTemplateExporterTest extends JMockTest {

    private static final Log LOG = LogFactory.getLog(MetricTemplateExporterTest.class);

    public void testCanExport() throws Exception {
        final MeasurementDefinitionManagerLocal measurementDefinitionManager = context.mock(MeasurementDefinitionManagerLocal.class);
        final MeasurementScheduleManagerLocal measurementScheduleManager = context.mock(MeasurementScheduleManagerLocal.class);
        context.checking(new Expectations() {
            {
                allowing(measurementDefinitionManager).findMeasurementDefinitionsByCriteria(with(any(Subject.class)), with(any(MeasurementDefinitionCriteria.class)));
                will(returnValue(getFakeMeasurementDefinitions()));
View Full Code Here

        request.setAttribute("dampenDurationCount", AlertDampening.Category.DURATION_COUNT.ordinal());

        request.setAttribute("noneDeleted", Constants.ALERT_CONDITION_NONE_DELETED);

        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
        MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
        ConfigurationManagerLocal configurationManager = LookupUtil.getConfigurationManager();

        Subject subject = RequestUtils.getSubject(request);
        Resource resource = RequestUtils.getResource(request);
        ResourceGroup group = RequestUtils.getResourceGroupIfExists(request);

        ResourceType type = null;
        if (resource != null) {
            // resource alert definition
            type = resource.getResourceType();
        } else if (group != null) {
            // group alert definition
            type = group.getResourceType();
        } else {
            // template alert definition
            type = RequestUtils.getResourceType(request);
        }

        defForm.setResourceType(type.getId());

        List<MeasurementDefinition> dataDefinitions = definitionManager.findMeasurementDefinitionsByResourceType(
            subject, type.getId(), DataType.MEASUREMENT, null);

        List<MeasurementDefinition> calltimeDefinitions = definitionManager.findMeasurementDefinitionsByResourceType(
            subject, type.getId(), DataType.CALLTIME, null);

        List<MeasurementDefinition> traitDefinitions = definitionManager.findMeasurementDefinitionsByResourceType(
            subject, type.getId(), DataType.TRAIT, null);

        List<RelatedOptionBean> baselines = new ArrayList<RelatedOptionBean>();

        if (resource != null) {
View Full Code Here

        HttpServletRequest request, HttpServletResponse response) throws Exception {
        log.trace("Executing ConfigMetricsFormPrepareAction...");

        Subject subject = WebUtility.getSubject(request);
        MeasurementScheduleManagerLocal scheduleManager = LookupUtil.getMeasurementScheduleManager();
        MeasurementDefinitionManagerLocal definitionManager = LookupUtil.getMeasurementDefinitionManager();
        ResourceTypeManagerLocal rtManager = LookupUtil.getResourceTypeManager();

        // NOTE: This action will be passed either a resourceTypeId OR a resourceId or a groupID or type+parent
        boolean configuringDefaultSchedules = false;
        int type = WebUtility.getOptionalIntRequestParameter(request, "type", -1);
        int parent = WebUtility.getOptionalIntRequestParameter(request, "parent", -1);

        // If only a type is present, we want the defaults
        if ((type > 0) && (parent == -1)) {
            configuringDefaultSchedules = true;
        }

        PageList<MeasurementScheduleComposite> measurementSchedules = null;
        PageControl pageControl = WebUtility.getPageControl(request);
        int groupId = WebUtility.getOptionalIntRequestParameter(request, "groupId", -1);
        if (configuringDefaultSchedules || (groupId > 0) || ((type > 0) && (parent > 0))) {
            pageControl.initDefaultOrderingField("md.name"); // underlying query runs over the MeasurementDefinition
        } else {
            pageControl.initDefaultOrderingField("ms.definition.name");
        }

        // We never want pagination for the schedules table, so don't allow user to change ps to anything other than -1.
        pageControl.setPageSize(PageControl.SIZE_UNLIMITED);

        if (configuringDefaultSchedules) {
            int resourceTypeId = type;
            log.debug("Obtaining default metric schedules for resource type " + resourceTypeId + "...");
            List<MeasurementDefinition> definitions = definitionManager.findMeasurementDefinitionsByResourceType(
                subject, resourceTypeId, null, null);
            List<MeasurementScheduleComposite> composites = new ArrayList<MeasurementScheduleComposite>();
            for (MeasurementDefinition definition : definitions) {
                composites.add(new MeasurementScheduleComposite(definition, definition.isDefaultOn(), definition
                    .getDefaultInterval()));
View Full Code Here

TOP

Related Classes of org.rhq.enterprise.server.measurement.MeasurementDefinitionManagerLocal

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.