Package org.rhq.core.domain.measurement

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


        MeasurementDefinition metricDef = createResourceWithMetricSchedule();
        createAlertDefinitionWithOneOutsideRangeCondition(metricDef, resource.getId()); // this test would fail if we used createAlertDefinitionWithTwoConditionsALL

        // re-load the resource so we get the measurement schedule
        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - one value that is inside our range, so no alerts are fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(60), request, 50.0)); // 50 is inside the range 40...60
View Full Code Here


        MeasurementDefinition metricDef = createResourceWithMetricSchedule();
        AlertDefinition alertDef = createAlertDefinitionWithTwoConditionsALL(metricDef, resource.getId());

        // re-load the resource so we get the measurement schedule
        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent
        // with a single metric that makes a condition trigger but does not fire an alert
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
View Full Code Here

        AlertCondition condition = alertDef.getConditions().iterator().next();
        int conditionId = condition.getId();

        // re-load the resource so we get the measurement schedule
        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - one values that fits in our range, so 1 alert is fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataNumeric(getTimestamp(15), request, 50.0)); // 50 < 60 AND 50 > 40
View Full Code Here

        AlertCondition condition = alertDef.getConditions().iterator().next();
        int conditionId = condition.getId();

        // re-load the resource so we get the measurement schedule
        final Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        // simulate a measurement report coming from the agent - one values that changes value, so 1 alert is fired
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(schedule);
        MeasurementReport report = new MeasurementReport();
        report.addData(new MeasurementDataTrait(getTimestamp(15), request, "Foo"));
View Full Code Here

        MeasurementDefinition measDef = createResourceWithMetricSchedule();

        createAlertDefinitionWithDampening(measDef, resource.getId());

        Resource resourceWithSchedules = loadResourceWithSchedules(resource.getId());
        MeasurementSchedule schedule = resourceWithSchedules.getSchedules().iterator().next();

        //the dampening is set for 3 consecutive matches.
        //we want to test that the agent cache reload doesn't confuse the counting

        //first, send 2 matches
View Full Code Here

        assert resource != null && resource.getId() > 0 : "failed to create test resource";

        executeInTransaction(false, new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                MeasurementSchedule schedule = new MeasurementSchedule(metricDef, resource);
                em.persist(schedule);
            }
        });

        // create a server which attaches our agent to it - we need this for the alert subsystem to do its thing
View Full Code Here

            PageList<CallTimeDataComposite> calltimeData = LookupUtil.getCallTimeDataManager()
                .findCallTimeDataForResource(overlord, calltimeScheduleId, 0, Long.MAX_VALUE, new PageControl());
            assertEquals("didn't purge all calltime data", 0, calltimeData.getTotalSize());

            // check trait data
            MeasurementSchedule traitSchedule = null;
            for (MeasurementSchedule sched : res.getSchedules()) {
                if (sched.getDefinition().getDataType() == DataType.TRAIT) {
                    traitSchedule = sched;
                    break;
                }
            }
            assertNotNull("why don't we have a trait schedule?", traitSchedule);

            List<MeasurementDataTrait> persistedTraits = LookupUtil.getMeasurementDataManager().findTraits(overlord,
                res.getId(), traitSchedule.getDefinition().getId());
            assertEquals("bad purge of trait data: " + persistedTraits.size(), 1, persistedTraits.size());

        } finally {
            getTransactionManager().rollback();
        }
View Full Code Here

        }

    }

    private void createNewTraitData(Resource res, long timestamp, int count) {
        MeasurementSchedule traitSchedule = null;
        for (MeasurementSchedule sched : res.getSchedules()) {
            if (sched.getDefinition().getDataType() == DataType.TRAIT) {
                traitSchedule = sched;
                break;
            }
        }
        assertNotNull("why don't we have a trait schedule?", traitSchedule);

        MeasurementDataManagerLocal mgr = LookupUtil.getMeasurementDataManager();

        MeasurementScheduleRequest msr = new MeasurementScheduleRequest(traitSchedule);

        Set<MeasurementDataTrait> dataset = new HashSet<MeasurementDataTrait>();
        for (int i = 0; i < count; i++) {
            dataset.add(new MeasurementDataTrait(timestamp + i, msr, "DataPurgeJobTestTraitValue" + i));
        }
        mgr.addTraitData(dataset);

        List<MeasurementDataTrait> persistedTraits = mgr.findTraits(LookupUtil.getSubjectManager().getOverlord(),
            res.getId(), traitSchedule.getDefinition().getId());
        assertEquals("did not persist trait data:" + persistedTraits.size() + ":" + persistedTraits, count,
            persistedTraits.size());
    }
View Full Code Here

        assertEquals("did not persist trait data:" + persistedTraits.size() + ":" + persistedTraits, count,
            persistedTraits.size());
    }

    private void createNewCalltimeData(Resource res, long timestamp, int count) {
        MeasurementSchedule calltimeSchedule = null;
        for (MeasurementSchedule sched : res.getSchedules()) {
            if (sched.getDefinition().getDataType() == DataType.CALLTIME) {
                calltimeSchedule = sched;
                break;
            }
        }
        assertNotNull("why don't we have a calltime schedule?", calltimeSchedule);

        MeasurementScheduleRequest msr = new MeasurementScheduleRequest(calltimeSchedule);

        Set<CallTimeData> dataset = new HashSet<CallTimeData>();
        CallTimeData data = new CallTimeData(msr);

        for (int i = 0; i < count; i++) {
            for (int j = 0; j < count; j++) {
                data.addCallData("DataPurgeJobTestCalltimeData" + j, new Date(timestamp), 777);
            }
        }

        dataset.add(data);

        CallTimeDataManagerLocal mgr = LookupUtil.getCallTimeDataManager();
        mgr.addCallTimeData(dataset);

        PageList<CallTimeDataComposite> persistedData = mgr.findCallTimeDataForResource(LookupUtil.getSubjectManager()
            .getOverlord(), calltimeSchedule.getId(), timestamp - 1L, timestamp + count + 1L, new PageControl());
        // just a few sanity checks
        assertEquals("did not persist all calltime data, only persisted: " + persistedData.getTotalSize(), count,
            persistedData.getTotalSize());
        assertEquals("did not persist all endpoint calltime data, only persisted: " + persistedData.get(0).getCount(),
            count, persistedData.get(0).getCount());
View Full Code Here

            def.setDefaultOn(true);
            def.setDestinationType("DataPurgeJobTestDestType");
            def.setDisplayName(def.getName());
            def.setDisplayType(DisplayType.SUMMARY);
            em.persist(def);
            MeasurementSchedule schedule = new MeasurementSchedule(def, resource);
            em.persist(schedule);
            def.addSchedule(schedule);
            resource.addSchedule(schedule);

            // add trait schedule
            def = new MeasurementDefinition(resourceType, "DataPurgeJobTestTraitMeasDef");
            def.setCategory(MeasurementCategory.PERFORMANCE);
            def.setDataType(DataType.TRAIT);
            def.setDefaultInterval(12345);
            def.setDefaultOn(true);
            def.setDisplayName(def.getName());
            def.setDisplayType(DisplayType.SUMMARY);
            em.persist(def);
            schedule = new MeasurementSchedule(def, resource);
            em.persist(schedule);
            def.addSchedule(schedule);
            resource.addSchedule(schedule);

            // add normal measurment schedule
            def = new MeasurementDefinition(resourceType, "DataPurgeJobTestNormalMeasDef");
            def.setCategory(MeasurementCategory.PERFORMANCE);
            def.setDataType(DataType.MEASUREMENT);
            def.setDefaultInterval(12345);
            def.setDefaultOn(true);
            def.setDisplayName(def.getName());
            def.setDisplayType(DisplayType.SUMMARY);
            em.persist(def);
            schedule = new MeasurementSchedule(def, resource);
            em.persist(schedule);
            def.addSchedule(schedule);
            resource.addSchedule(schedule);

        } catch (Exception e) {
View Full Code Here

TOP

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

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.