Package org.rhq.core.domain.measurement

Examples of org.rhq.core.domain.measurement.MeasurementDefinition


            traitDef, asList("id", "resourceType", "schedules", "alertCondition"));
    }

    @Test(groups = { "plugin.metadata", "Metrics.NewPlugin" }, dependsOnMethods = { "persistNewMetrics" })
    public void persistNewNumericMeasurementDef() {
        MeasurementDefinition measurementDef = loadMeasurementDef("metric2", "MetricServer1");

        MeasurementDefinition expected = new MeasurementDefinition("metric2", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MEGABYTES, NumericType.TRENDSUP, false, 30000, DisplayType.DETAIL);
        expected.setRawNumericType(null);
        expected.setDescription("Metric 2");
        expected.setDisplayName("metric2");
        expected.setDisplayOrder(2);

        AssertUtils.assertPropertiesMatch("Failed to persist properties for numeric metric definition", expected,
            measurementDef, asList("id", "resourceType", "schedules", "alertCondition"));

        MeasurementDefinition perMinuteDef = loadMeasurementDef("metric2", "MetricServer1", "metric2 per Minute");

        expected = new MeasurementDefinition(measurementDef);
        expected.setDisplayName("metric2 per Minute");
        expected.setDisplayOrder(3);
        expected.setDefaultOn(true);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setRawNumericType(measurementDef.getNumericType());
View Full Code Here


            perMinuteDef, asList("id", "resourceType", "schedules", "alertCondition"));
    }

    @Test(groups = { "plugin.metadata", "Metrics.NewPlugin" }, dependsOnMethods = { "persistNewMetrics" })
    public void persistNewCallTimeDef() {
        MeasurementDefinition calltimeDef = loadMeasurementDef("metric3", "MetricServer1");

        MeasurementDefinition expected = new MeasurementDefinition("metric3", MeasurementCategory.THROUGHPUT,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 30000, DisplayType.DETAIL);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setDestinationType("myMethod");
        expected.setDescription("Metric 3");
        expected.setDisplayName("metric3");
        expected.setDisplayOrder(4);

        AssertUtils.assertPropertiesMatch("Failed to create calltime metric definition", expected, calltimeDef,
            asList("id", "resourceType", "schedules", "alertCondition"));
    }
View Full Code Here

            asList("id", "resourceType", "schedules", "alertCondition"));
    }

    @Test(groups = { "plugin.metadata", "Metrics.NewPlugin" }, dependsOnMethods = { "persistNewMetrics" })
    public void availabilityDefaultTest() {
        MeasurementDefinition serverAvailDef = loadMeasurementDef("rhq.availability", "MetricServer1",
            MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);

        MeasurementDefinition expected = new MeasurementDefinition("rhq.availability",
            MeasurementCategory.AVAILABILITY, MeasurementUnits.NONE, DataType.AVAILABILITY, true,
            MeasurementDefinition.AVAILABILITY_DEFAULT_PERIOD_SERVER, DisplayType.DETAIL);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setDisplayName(MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);
        expected.setDescription(MeasurementDefinition.AVAILABILITY_DESCRIPTION);

        AssertUtils.assertPropertiesMatch("Failed to create avail metric definition", expected, serverAvailDef,
            asList("id", "resourceType", "destinationType", "displayOrder", "alertCondition", "schedules"));

        MeasurementDefinition serviceAvailDef = loadMeasurementDef("rhq.availability", "MetricService1",
            MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);

        expected = new MeasurementDefinition("rhq.availability", MeasurementCategory.AVAILABILITY,
            MeasurementUnits.NONE, DataType.AVAILABILITY, false, 120000, DisplayType.DETAIL);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setDisplayName(MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);
        expected.setDescription(MeasurementDefinition.AVAILABILITY_DESCRIPTION);

        AssertUtils.assertPropertiesMatch("Failed to create avail metric definition", expected, serviceAvailDef,
            asList("id", "resourceType", "destinationType", "displayOrder", "schedules", "alertCondition"));

        serviceAvailDef = loadMeasurementDef("rhq.availability", "MetricService2",
            MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);

        expected = new MeasurementDefinition("rhq.availability", MeasurementCategory.AVAILABILITY,
            MeasurementUnits.NONE, DataType.AVAILABILITY, true,
            MeasurementDefinition.AVAILABILITY_DEFAULT_PERIOD_SERVICE, DisplayType.DETAIL);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setDisplayName(MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);
        expected.setDescription(MeasurementDefinition.AVAILABILITY_DESCRIPTION);
View Full Code Here

            "metricDefinitions", asList("metric1", "rhq.availability"));
    }

    @Test(groups = { "plugin.metadata", "Metrics.UpradePlugin" }, dependsOnMethods = { "upgradeMetricsPlugin" })
    public void changeTraitDefToMeasurementDef() {
        MeasurementDefinition measurementDef = loadMeasurementDef("metric1", "MetricServer3");

        MeasurementDefinition expected = new MeasurementDefinition("metric1", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.MEASUREMENT, NumericType.TRENDSUP, false, 30000, DisplayType.DETAIL);
        expected.setRawNumericType(null);
        expected.setDefaultInterval(30000);
        expected.setDescription("Metric One");
        expected.setDisplayName("metric1");
        expected.setDisplayOrder(1);

        AssertUtils.assertPropertiesMatch("Failed to change trait definition to a measurement defintion", expected,
            measurementDef, asList("id", "resourceType", "schedules", "alertCondition"));

        MeasurementDefinition perMinuteDef = loadMeasurementDef("metric1", "MetricServer3", "metric1 per Minute");
        expected.setDisplayName("metric1 per Minute");
        expected.setDisplayOrder(2);
        expected.setDefaultInterval(60000);
        expected.setDefaultOn(false);
        expected.setNumericType(NumericType.DYNAMIC);
View Full Code Here

        assertEquals("Failed to delete metric definitions", 0, metricDefs.size());
    }

    @Test(groups = { "plugin.metadata", "Metrics.UpradePlugin" }, dependsOnMethods = { "upgradeMetricsPlugin" })
    public void availabilityOverrideTest() {
        MeasurementDefinition serverAvailDef = loadMeasurementDef("rhq.availability", "MetricServer1",
            MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);

        MeasurementDefinition expected = new MeasurementDefinition("rhq.availability",
            MeasurementCategory.AVAILABILITY, MeasurementUnits.NONE, DataType.AVAILABILITY, true, 120000,
            DisplayType.DETAIL);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setDisplayName(MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);
        expected.setDescription(MeasurementDefinition.AVAILABILITY_DESCRIPTION);

        AssertUtils.assertPropertiesMatch("Failed to create avail metric definition", expected, serverAvailDef,
            asList("id", "resourceType", "destinationType", "displayOrder", "schedules", "alertCondition"));

        MeasurementDefinition serviceAvailDef = loadMeasurementDef("rhq.availability", "MetricService1",
            MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);

        // interval can not be changed by new plugin version if not at the category default
        expected = new MeasurementDefinition("rhq.availability", MeasurementCategory.AVAILABILITY,
            MeasurementUnits.NONE, DataType.AVAILABILITY, true, 120000, DisplayType.DETAIL);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setDisplayName(MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);
        expected.setDescription(MeasurementDefinition.AVAILABILITY_DESCRIPTION);

        AssertUtils.assertPropertiesMatch("Failed to create avail metric definition", expected, serviceAvailDef,
            asList("id", "resourceType", "destinationType", "displayOrder", "schedules", "alertCondition"));

        serviceAvailDef = loadMeasurementDef("rhq.availability", "MetricService2",
            MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);

        expected = new MeasurementDefinition("rhq.availability", MeasurementCategory.AVAILABILITY,
            MeasurementUnits.NONE, DataType.AVAILABILITY, true, 480000, DisplayType.DETAIL);
        expected.setNumericType(NumericType.DYNAMIC);
        expected.setDisplayName(MeasurementDefinition.AVAILABILITY_DISPLAY_NAME);
        expected.setDescription(MeasurementDefinition.AVAILABILITY_DESCRIPTION);
View Full Code Here

        List<Resource> resources = q.getResultList();
        Resource res = resources.get(0);
        if (!(res.getResourceType().getCategory()== ResourceCategory.PLATFORM))
            res = resourceManager.getPlaformOfResource(overlord,res.getId());
        ResourceType type = res.getResourceType();
        MeasurementDefinition def = null;
        Set<MeasurementDefinition> definitions = type.getMetricDefinitions();
        for (MeasurementDefinition d : definitions) {
            if (d.getName().equals("myCallTime"))
                def = d;
        }
View Full Code Here

        return executeInTransaction(false, new TransactionCallbackReturnable<MeasurementSchedule>() {
            @Override
            public MeasurementSchedule execute() throws Exception {
                EntityManager em = getEntityManager();

                MeasurementDefinition definition = new MeasurementDefinition(resourceType, DYNAMIC_DEF_NAME +
                    measurementDefs.size());
                definition.setDefaultOn(true);
                definition.setDataType(MEASUREMENT);
                definition.setMeasurementType(DYNAMIC);
                em.persist(definition);

                MeasurementSchedule schedule = new MeasurementSchedule(definition, resource);
                schedule.setEnabled(true);
                resource.addSchedule(schedule);
View Full Code Here

        em.persist(theAgent);

        theResourceType = new ResourceType("test-plat", "test-plugin", ResourceCategory.PLATFORM, null);
        em.persist(theResourceType);

        definitionCt1 = new MeasurementDefinition("CT-Def1", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 60000, DisplayType.SUMMARY);
        definitionCt1.setResourceType(theResourceType);
        em.persist(definitionCt1);

        definitionCt2 = new MeasurementDefinition("CT-Def2", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 60000, DisplayType.SUMMARY);
        definitionCt2.setResourceType(theResourceType);
        em.persist(definitionCt2);

        resource1 = new Resource("test-platform-key1", "test-platform-name", theResourceType);
View Full Code Here

        em.persist(theAgent);

        theResourceType = new ResourceType("test-plat", "test-plugin", ResourceCategory.PLATFORM, null);
        em.persist(theResourceType);

        definitionCt1 = new MeasurementDefinition("CT-Def1", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 60000, DisplayType.SUMMARY);
        definitionCt1.setResourceType(theResourceType);
        em.persist(definitionCt1);

        definitionCt2 = new MeasurementDefinition("CT-Def2", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 60000, DisplayType.SUMMARY);
        definitionCt2.setResourceType(theResourceType);
        em.persist(definitionCt2);

        definitionCt3 = new MeasurementDefinition("CT-Def3", MeasurementCategory.PERFORMANCE,
            MeasurementUnits.MILLISECONDS, DataType.CALLTIME, true, 60000, DisplayType.SUMMARY);
        definitionCt3.setResourceType(theResourceType);
        em.persist(definitionCt3);

        resource1 = new Resource("test-platform-key1", "test-platform-name", theResourceType);
View Full Code Here

    @Override
    public ListGridRecord copyValues(MeasurementScheduleComposite from) {

        ListGridRecord record = new ListGridRecord();
        MeasurementDefinition measurementDefinition = from.getMeasurementDefinition();

        record.setAttribute(ATTR_DEFINITION_ID, measurementDefinition.getId());
        record.setAttribute(ATTR_DISPLAY_NAME, measurementDefinition.getDisplayName());
        record.setAttribute(ATTR_DESCRIPTION, measurementDefinition.getDescription());
        record.setAttribute(ATTR_DATA_TYPE, measurementDefinition.getDataType().name().toLowerCase());
        record.setAttribute(ATTR_ENABLED, from.getCollectionEnabled());
        record.setAttribute(ATTR_INTERVAL, from.getCollectionInterval());

        return record;
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.measurement.MeasurementDefinition

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.