Package org.rhq.core.domain.measurement

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


        // deleteResource removes the agent, so we can't have two direct platforms for it, make one a child of the other
        platform.addChildResource(platform2);
        em.persist(platform2);
        platform2.setAgent(agent);

        measDef = new MeasurementDefinition(platformType, "testAutoBaseline");
        measDef.setDefaultOn(true);
        measDef.setDisplayName("testAutoBaseline Measurement Display Name");
        measDef.setMeasurementType(NumericType.DYNAMIC);
        em.persist(measDef);
View Full Code Here


        platformType = new ResourceType("testplatAB", "p", ResourceCategory.PLATFORM, null);
        em.persist(platformType);

        for (int m = 0; m < measurementCount; m++) {
            MeasurementDefinition def = new MeasurementDefinition(platformType, "testAutoBaselineMeasDef" + m);
            def.setDefaultOn(true);
            def.setDisplayName("testAutoBaseline Measurement Display Name" + m);
            def.setMeasurementType(NumericType.DYNAMIC);
            em.persist(def);
            allDefs.add(def);
        }

        em.flush();
        em.clear();

        System.out.println("Populating test inventory with [" + resourceCount + "] resources.");

        agent = new Agent("test-agent", "localhost", 1234, "", "randomToken");
        em.persist(agent);

        Resource root = null;
        for (int r = 0; r < resourceCount; r++) {
            Resource resource = new Resource(String.valueOf(r), "testAutoBaselineResource" + r, platformType);
            resource.setUuid("" + new Random().nextInt());
            if (root == null) {
                root = resource;
            } else {
                root.addChildResource(resource);
            }
            em.persist(resource);
            allResources.add(resource);
            resource.setAgent(agent);

            for (MeasurementDefinition def : allDefs) {
                MeasurementSchedule sched = new MeasurementSchedule(def, resource);
                sched.setEnabled(true);
                resource.addSchedule(sched);
                def.addSchedule(sched);
                em.persist(sched);
                allScheds.add(sched);
            }

            if ((r % 50) == 0) {
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.MEASUREMENT, true, 120000L, DisplayType.SUMMARY);
        definitionCt1.setResourceType(theResourceType);
        em.persist(definitionCt1);

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

            // we need to make sure we have the full measurement definition, including the units.
            // this is so we can display the condition values with the proper units. If an alert
            // condition is a measurement condition, but the measurement definition isn't the full
            // definition, look up the full definition from the resource type and use it.
            for (AlertCondition alertCondition : set) {
                MeasurementDefinition measDef = alertCondition.getMeasurementDefinition();
                if (measDef != null) {
                    if (measDef.getUnits() == null) {
                        MeasurementDefinition fullMeasDef = findMeasurementDefinition(measDef.getId());
                        if (fullMeasDef != null) {
                            alertCondition.setMeasurementDefinition(fullMeasDef);
                        }
                    }
                }
View Full Code Here

                throw new InvalidAlertDefinitionException(
                    "AlertDefinitionManager does not yet support condition category: " + alertConditionCategory);
            }
            if (alertConditionCategory == AlertConditionCategory.BASELINE) {

                MeasurementDefinition def = alertCondition.getMeasurementDefinition();
                def = entityManager.getReference(MeasurementDefinition.class, def.getId());
                NumericType numType = def.getNumericType();
                if (numType == null) {
                    def = entityManager.getReference(MeasurementDefinition.class, def.getId());
                    numType = def.getNumericType();
                }
                if (numType != NumericType.DYNAMIC) {
                    throw new InvalidAlertDefinitionException("Invalid Condition: '" + def.getDisplayName()
                        + "' is a trending metric, and thus will never have baselines calculated for it.");
                }
            }
        }
View Full Code Here

    private static PageList<MeasurementDefinition> getFakeMeasurementDefinitions() {
        List<MeasurementDefinition> ret = new ArrayList<MeasurementDefinition>();

        ResourceType rt = new ResourceType("fakeType", "fakePlugin", ResourceCategory.PLATFORM, null);

        ret.add(new MeasurementDefinition(rt, "m1"));
        ret.add(new MeasurementDefinition(rt, "m2"));
        ret.add(new MeasurementDefinition(rt, "m3"));

        for(int i = 0; i < ret.size(); ++i) {
            ret.get(i).setId(i + 1);
        }
       
View Full Code Here

    public void testNonMatchingMeasurementDefinitionsAreIgnored() {
        final TestPrerequisities prereqs = new TestPrerequisities(context);

        //some data to supply
        MeasurementDefinition def = new MeasurementDefinition(FAKE_RESOURCE_TYPE, "fake");
        def.setId(1);
        def.setDefaultOn(true);
        def.setDefaultInterval(1000);

        //now we setup the prerequisites to return the faked results from the database
        //for the non-matching template, we want the "database" to return no results
        //while for the matching template, we want the "database" to return our own def.
        prereqs.setMeasurementDefinitions(Collections.singletonList(def));
View Full Code Here

        //correctly by the importer.
        importer.finishImport();
    }

    public void testCanUpdateEnablements() {
        MeasurementDefinition defToEnable = new MeasurementDefinition(FAKE_RESOURCE_TYPE, "enabled");
        MeasurementDefinition defToDisable = new MeasurementDefinition(FAKE_RESOURCE_TYPE, "disable");

        defToEnable.setId(1);
        defToEnable.setDefaultOn(true);
        defToEnable.setDefaultInterval(1000);

        defToDisable.setId(2);
        defToDisable.setDefaultOn(false);
        defToDisable.setDefaultInterval(2000);

        final TestPrerequisities prereqs = new TestPrerequisities(context);
        prereqs.setMeasurementDefinitions(Arrays.asList(defToEnable, defToDisable));

        context.checking(new Expectations() {
View Full Code Here

        importer.finishImport();

    }

    public void testCanUpdateSchedules() {
        MeasurementDefinition def = new MeasurementDefinition(FAKE_RESOURCE_TYPE, "def");
        def.setId(1);
        def.setDefaultOn(true);
        def.setDefaultInterval(1000);

        final TestPrerequisities prereqs = new TestPrerequisities(context);
        prereqs.setMeasurementDefinitions(Collections.singletonList(def));

        context.checking(new Expectations() {
View Full Code Here

        //correctly by the importer.
        importer.finishImport();
    }

    public void testPerMetricUpdateScheduleOverrides() {
        MeasurementDefinition updatedDef = new MeasurementDefinition(FAKE_RESOURCE_TYPE, "def");
        updatedDef.setId(1);
        updatedDef.setDefaultOn(true);
        updatedDef.setDefaultInterval(1000);
        MeasurementDefinition notUpdatedDef = new MeasurementDefinition(FAKE_RESOURCE_TYPE, "ndef");
        notUpdatedDef.setId(2);
        notUpdatedDef.setDefaultOn(true);
        notUpdatedDef.setDefaultInterval(2000);

        final TestPrerequisities prereqs = new TestPrerequisities(context);
        prereqs.setMeasurementDefinitions(Arrays.asList(updatedDef, notUpdatedDef));

        context.checking(new Expectations() {
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.