Examples of AvailabilityReport


Examples of org.rhq.core.domain.discovery.AvailabilityReport

    public void testAvailReport() throws Exception {
        Assert.assertTrue(pluginContainer.isStarted());
        Assert.assertTrue(pluginContainer.isRunning());
        AvailabilityExecutor executor = new ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
        dumpContainers("testAvailReport() Start");
        AvailabilityReport report = executor.call();
        dumpContainers("testAvailReport() After First Avail Check");
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
        List<Datum> availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource ID should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
        }
        AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
        assertScan(scan, true, true, 29, 29, 29, 28, 0, 0);

        // do a forced avail check again - nothing changed, so we should have an empty report
        report = executor.call();
        dumpContainers("testAvailReport() After Second Avail Check");
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), true, "Second report should have been changes-only");
        Assert.assertEquals(report.getResourceAvailability().isEmpty(), true, "Nothing changed, should be empty");
        scan = executor.getMostRecentScanHistory();
        assertScan(scan, true, false, 29, 0, 29, 28, 0, 0);

        // make one of the top parents down and see all other children are down, force a scan of all to make sure we pick
        // up the changed resource.
        AvailResourceComponent downParent = this.parentComponents1.iterator().next();
        downParent.setNextAvailability(AvailabilityType.DOWN);
        report = executor.call();
        dumpContainers("testAvailReport() After Third Avail Check");
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), true, "report should have been changes-only");
        availData = report.getResourceAvailability();
        Assert.assertEquals(availData.size(), 7, "Should have 1 parent, its 2 children and 4 grandchildren");
        for (Datum datum : availData) {
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.DOWN);
        }
        scan = executor.getMostRecentScanHistory();
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

    @Test(groups = "pc.itest.avail", priority = 21)
    public void testScheduling() throws Exception {
        Assert.assertTrue(pluginContainer.isStarted());
        Assert.assertTrue(pluginContainer.isRunning());
        AvailabilityExecutor executor = new ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
        AvailabilityReport report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
        List<Datum> availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
        }
        AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

    public void testForceChildrenOfParentUp() throws Exception {
        Assert.assertTrue(pluginContainer.isStarted());
        Assert.assertTrue(pluginContainer.isRunning());
        // don't use a ForceAvailabilityExecutor for this test, we want to manipulate what gets checked
        AvailabilityExecutor executor = new AvailabilityExecutor(this.pluginContainer.getInventoryManager());
        AvailabilityReport report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
        List<Datum> availData = report.getResourceAvailability();
        int numUp = 0;
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            if (datum.getAvailabilityType() == AvailabilityType.UP) {
                ++numUp;
            }
        }
        Assert.assertEquals(numUp, 1);
        // only the platform should have been checked, all others should only have been scheduled for a check
        AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
        assertScan(scan, false, true, 29, 0, 1, 28, 0, 0);

        // At this point all of the non-platform resources are scheduled but still at NULL avail

        // Manipulate the scheduled time of the "1" servers so they are checked
        List<Set<ResourceContainer>> containerSets = new ArrayList<Set<ResourceContainer>>();
        containerSets.add(parentContainers1);
        long now = System.currentTimeMillis();
        for (Set<ResourceContainer> cs : containerSets) {
            for (ResourceContainer c : cs) {
                c.setAvailabilityScheduleTime(now);
            }
        }

        // make sure nothing else is scheduled to be checked
        containerSets.clear();
        containerSets.add(childContainers1);
        containerSets.add(grandchildContainers1);
        containerSets.add(parentContainers2);
        containerSets.add(childContainers2);
        containerSets.add(grandchildContainers2);
        long later = now + 10000000L;
        for (Set<ResourceContainer> cs : containerSets) {
            for (ResourceContainer c : cs) {
                c.setAvailabilityScheduleTime(later);
            }
        }

        // a changes-only report, even though only 2 checks are scheduled, we should see checks for half
        // the resources, as the children will be forced. (they should change from null to UP).  The scheduled
        // checks should see their schedules pushed out, but the forced checks should be rescheduled randomly
        report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), true, "Second report should have been changes-only");
        Assert.assertEquals(report.getResourceAvailability().size(), 14, "should report half the resources");
        availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
        }
        scan = executor.getMostRecentScanHistory();
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

    public void testDeferToParentDown() throws Exception {
        Assert.assertTrue(pluginContainer.isStarted());
        Assert.assertTrue(pluginContainer.isRunning());
        // don't use a ForceAvailabilityExecutor for this test, we want to manipulate what gets checked
        AvailabilityExecutor executor = new AvailabilityExecutor(this.pluginContainer.getInventoryManager());
        AvailabilityReport report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
        List<Datum> availData = report.getResourceAvailability();
        int numUp = 0;
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be > zero since it should be committed";
            if (datum.getAvailabilityType() == AvailabilityType.UP) {
                ++numUp;
            }
        }
        Assert.assertEquals(numUp, 1);
        // only the platform should have been checked, all others should only have been scheduled for a check
        AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
        assertScan(scan, false, true, 29, 0, 1, 28, 0, 0);

        // At this point all of the non-platform resources are scheduled but still at NULL avail

        // Manipulate the scheduled time of the "1" servers so they are checked
        List<Set<ResourceContainer>> containerSets = new ArrayList<Set<ResourceContainer>>();
        containerSets.add(parentContainers1);
        long now = System.currentTimeMillis();
        for (Set<ResourceContainer> cs : containerSets) {
            for (ResourceContainer c : cs) {
                c.setAvailabilityScheduleTime(now);
            }
        }

        // make sure nothing else is scheduled to be checked
        containerSets.clear();
        containerSets.add(childContainers1);
        containerSets.add(grandchildContainers1);
        containerSets.add(parentContainers2);
        containerSets.add(childContainers2);
        containerSets.add(grandchildContainers2);
        long later = now + 10000000L;
        for (Set<ResourceContainer> cs : containerSets) {
            for (ResourceContainer c : cs) {
                c.setAvailabilityScheduleTime(later);
            }
        }

        // make the "1" servers return DOWN and ensure all other children are down, even though their schedules
        // are not yet met.
        for (AvailResourceComponent downParent : this.parentComponents1) {
            downParent.setNextAvailability(AvailabilityType.DOWN);
        }

        // a changes-only report, even though only 2 checks are scheduled, we should see checks for half
        // the resources, as the children should defer to the DOWN parent. (they should change from null to DOWN).
        // The scheduled checks should see their schedules pushed out but the deferred checks should not, their
        // schedules remain unchanged in this scenario.
        report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), true, "Second report should have been changes-only");
        Assert.assertEquals(report.getResourceAvailability().size(), 14, "should report half the resources");
        availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.DOWN, "should be DOWN");
        }
        scan = executor.getMostRecentScanHistory();
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

    public void testCheckOnlyEligible() throws Exception {
        Assert.assertTrue(pluginContainer.isStarted());
        Assert.assertTrue(pluginContainer.isRunning());
        // Force all the avails to UP to start so we can avoid the scenario in  testForceChildrenOfParentUp()
        AvailabilityExecutor executor = new ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
        AvailabilityReport report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
        List<Datum> availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
        }
        AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
        assertScan(scan, true, true, 29, 28, 29, 28, 0, 0);

        // don't use a ForceAvailabilityExecutor for this scan, we want to manipulate what gets checked.
        // by default new executors always do a full scan to start, we don't want that
        executor = new AvailabilityExecutor(this.pluginContainer.getInventoryManager());
        executor.sendChangesOnlyReportNextTime();

        // Manipulate the scheduled times such that the "1" resources should be checked and the "2"s should not
        List<Set<ResourceContainer>> containerSets = new ArrayList<Set<ResourceContainer>>();
        containerSets.add(parentContainers1);
        containerSets.add(childContainers1);
        containerSets.add(grandchildContainers1);
        long now = System.currentTimeMillis();
        for (Set<ResourceContainer> cs : containerSets) {
            for (ResourceContainer c : cs) {
                c.setAvailabilityScheduleTime(now);
            }
        }

        containerSets.clear();
        containerSets.add(parentContainers2);
        containerSets.add(childContainers2);
        containerSets.add(grandchildContainers2);
        long later = now + 10000000L;
        for (Set<ResourceContainer> cs : containerSets) {
            for (ResourceContainer c : cs) {
                c.setAvailabilityScheduleTime(later);
            }
        }

        // a changes-only report, check half the resources, no changes - should all be UP already. push out scheds for each
        report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), true, "Second report should have been changes-only");
        Assert.assertEquals(report.getResourceAvailability().size(), 0, "no changes, everything was already up");
        availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
        }
        scan = executor.getMostRecentScanHistory();
        assertScan(scan, false, false, 29, 0, 15, 0, 14, 0);

        // another quick scan should see no calls, check times should be pushed out at least a minute
        report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), true, "Third report should have been changes-only");
        Assert.assertEquals(report.getResourceAvailability().isEmpty(), true, "Nothing changed, should be empty");
        scan = executor.getMostRecentScanHistory();
        assertScan(scan, false, false, 29, 0, 1, 0, 0, 0);
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

    @Test(groups = "pc.itest.avail", priority = 21)
    public void testDeferToParent() throws Exception {
        Assert.assertTrue(pluginContainer.isStarted());
        Assert.assertTrue(pluginContainer.isRunning());
        AvailabilityExecutor executor = new ForceAvailabilityExecutor(this.pluginContainer.getInventoryManager());
        AvailabilityReport report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), false, "First report should have been a full report");
        List<Datum> availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
        }
        AvailabilityExecutor.Scan scan = executor.getMostRecentScanHistory();
        assertScan(scan, true, true, 29, 28, 29, 28, 0, 0);

        // disable the schedules for all "1" children
        List<Set<ResourceContainer>> containerSets = new ArrayList<Set<ResourceContainer>>();
        containerSets.add(childContainers1);
        containerSets.add(grandchildContainers1);
        long now = System.currentTimeMillis();
        for (Set<ResourceContainer> cs : containerSets) {
            for (ResourceContainer c : cs) {
                MeasurementScheduleRequest sched = c.getAvailabilitySchedule();
                sched.setEnabled(false);
                c.setAvailabilitySchedule(sched);
            }
        }

        // a changes-only report, force checks, no changes, ensure 1/2 children defer to parent
        report = executor.call();
        Assert.assertNotNull(report);
        Assert.assertEquals(report.isChangesOnlyReport(), true, "Second report should have been changes-only");
        Assert.assertEquals(report.getResourceAvailability().size(), 0, "no changes, everything was already up");
        availData = report.getResourceAvailability();
        for (Datum datum : availData) {
            assert datum.getResourceId() != 0 : "resource IDs should be != zero since it should be committed";
            Assert.assertEquals(datum.getAvailabilityType(), AvailabilityType.UP, "should be UP at the start");
        }
        scan = executor.getMostRecentScanHistory();
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

            throw new BadArgumentException("Availability","Platforms must not be set to DISABLED");
        }

        Agent agent = agentMgr.getAgentByResourceId(caller,resourceId);

        AvailabilityReport report = new AvailabilityReport(true, agent.getName());
        Availability availability = new Availability(resource, avail.getSince(), at);
        report.addAvailability(availability);

        availMgr.mergeAvailabilityReport(report);
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

*/
@Test
public class SerializableTest {
    public void testSerialization() {
        List<Serializable> objects = new ArrayList<Serializable>();
        Serializable[] simpleObjects = new Serializable[] { new AvailabilityReport("fakeAgent"), new PackageType(),
            new Architecture(), new Repo(), new ContentServiceRequest(), new ContentSource(), new ContentSourceType(),
            new InstalledPackage(), new Package(), new PackageInstallationStep(), new PackageType(),
            new PackageVersion() };
        objects.addAll(Arrays.asList(simpleObjects));

View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

        assert copy.getNumericData().size() == 1 : "-->" + copy.getNumericData();
        assert copy.getTraitData().size() == 1 : "-->" + copy.getTraitData();
    }

    public void testAvailabilityReport() {
        assert ensureSerializable(new AvailabilityReport(true, "the-agent-name")).isChangesOnlyReport();
        assert !ensureSerializable(new AvailabilityReport(false, "the-agent-name")).isChangesOnlyReport();
        assert !ensureSerializable(new AvailabilityReport("the-agent-name")).isChangesOnlyReport();
        assert ensureSerializable(new AvailabilityReport("the-agent-name")).getAgentName().equals("the-agent-name");

        AvailabilityReport report;

        report = new AvailabilityReport("the-agent-name");
        report.addAvailability(new Availability(new Resource(), AvailabilityType.UP));
        assert ensureSerializable(report).getResourceAvailability().size() == 1;

        report = new AvailabilityReport("the-agent-name");
        report.addAvailability(new Availability(new Resource(), AvailabilityType.UNKNOWN));
        assert ensureSerializable(report).getResourceAvailability().size() == 1;

        report = new AvailabilityReport("the-agent-name");
        report.addAvailability(new Availability(new Resource(), AvailabilityType.UP));
        report.addAvailability(new Availability(new Resource(), AvailabilityType.DOWN));
        report.addAvailability(new Availability(new Resource(), AvailabilityType.UNKNOWN));
        assert ensureSerializable(report).getResourceAvailability().size() == 3;
    }
View Full Code Here

Examples of org.rhq.core.domain.discovery.AvailabilityReport

        createAlertDefinitionWithAvailChangeCondition(resource.getId(), AlertConditionOperator.AVAIL_GOES_DOWN);
        createAlertDefinitionWithAvailChangeCondition(resource.getId(), AlertConditionOperator.AVAIL_GOES_NOT_UP);

        // resource has initial UNKNOWN ResourceAvailability and no Availability records. simulate an avail report
        // coming from the agent and setting the initial avail to UP.
        AvailabilityReport availReport = new AvailabilityReport(AGENT_NAME);
        availReport.addAvailability(new Datum(resource.getId(), AvailabilityType.UP, System.currentTimeMillis()));
        AvailabilityManagerLocal availManager = LookupUtil.getAvailabilityManager();
        availManager.mergeAvailabilityReport(availReport);

        // wait for our JMS messages to process and see if we get any alerts
        Thread.sleep(3000);

        PageList<Alert> alerts = getAlerts(resource.getId());
        assert alerts.size() == 0 : "No alert should have fired on the initial avail reporting: " + alerts;

        // Now simulate the down avail
        availReport = new AvailabilityReport(AGENT_NAME);
        availReport
            .addAvailability(new Datum(resource.getId(), AvailabilityType.DOWN, System.currentTimeMillis() + 10));
        availManager.mergeAvailabilityReport(availReport);

        // wait for our JMS messages to process and see if we get any alerts
        final PageList<Alert> finalAlerts = alerts;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.