Examples of AvailabilityReport


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

            setupResource();
            // platform: UNKNOWN(0) -->            
            commitAndClose();

            AvailabilityReport report = new AvailabilityReport(false, theAgent.getName());

            availPoints = availabilityManager.findAvailabilitiesForResource(overlord, theResource.getId(), 1,
                System.currentTimeMillis(), 3, false);
            assert availPoints.size() == 3 : "There is no avail data, but should still get 3 availability points";
            assert availPoints.get(0).getAvailabilityType() == UNKNOWN;
            assert availPoints.get(1).getAvailabilityType() == UNKNOWN;
            assert availPoints.get(2).getAvailabilityType() == UNKNOWN;

            Long startMillis = 60000L;
            avail = new Availability(theResource, startMillis, UP);
            report.addAvailability(avail);
            availabilityManager.mergeAvailabilityReport(report);
            // platform: UNKNOWN(0) --> UP(60000) -->           

            // our avail data point is right on the start edge
            availPoints = availabilityManager.findAvailabilitiesForResource(overlord, theResource.getId(), startMillis,
                startMillis + 10000, 3, false);
            assert availPoints.size() == 3 : "There is 1 avail data, but should still get 3 availability points";
            assert availPoints.get(0).getAvailabilityType() == UP;
            assert availPoints.get(1).getAvailabilityType() == UP;
            assert availPoints.get(2).getAvailabilityType() == UP;

            // our avail data point is right on the end edge
            availPoints = availabilityManager.findAvailabilitiesForResource(overlord, theResource.getId(),
                startMillis - 3, startMillis, 3, false);
            assert availPoints.size() == 3 : "There is 1 avail data, but should still get 3 availability points";
            assert availPoints.get(0).getAvailabilityType() == UNKNOWN;
            assert !availPoints.get(0).isKnown() : availPoints;
            assert availPoints.get(1).getAvailabilityType() == UNKNOWN;
            assert !availPoints.get(1).isKnown() : availPoints;
            assert availPoints.get(2).getAvailabilityType() == UNKNOWN;
            assert !availPoints.get(2).isKnown() : availPoints;

            availPoints = availabilityManager.findAvailabilitiesForResource(overlord, theResource.getId(),
                startMillis - 20000, startMillis + 10000, 3, false);
            assert availPoints.size() == 3 : "There is 1 avail data, but should still get 3 availability points";
            assert availPoints.get(0).getAvailabilityType() == UNKNOWN;
            assert !availPoints.get(0).isKnown() : availPoints;
            assert availPoints.get(1).getAvailabilityType() == UNKNOWN;
            assert !availPoints.get(1).isKnown() : availPoints;
            assert availPoints.get(2).getAvailabilityType() == UP : availPoints;

            availPoints = availabilityManager.findAvailabilitiesForResource(overlord, theResource.getId(),
                startMillis - 10000, startMillis + 20000, 3, false);
            assert availPoints.size() == 3 : "There is 1 avail data, but should still get 3 availability points";
            assert availPoints.get(0).getAvailabilityType() == UNKNOWN;
            assert !availPoints.get(0).isKnown() : availPoints;
            assert availPoints.get(1).getAvailabilityType() == UP;
            assert availPoints.get(1).isKnown() : availPoints;
            assert availPoints.get(2).getAvailabilityType() == UP;

            availPoints = availabilityManager.findAvailabilitiesForResource(overlord, theResource.getId(),
                startMillis - 20000, startMillis + 20000, 10, false);
            assert availPoints.size() == 10 : "There is 1 avail data, but should still get 10 availability points";
            assert availPoints.get(0).getAvailabilityType() == UNKNOWN : availPoints;
            assert !availPoints.get(0).isKnown() : availPoints;
            assert availPoints.get(1).getAvailabilityType() == UNKNOWN : availPoints;
            assert !availPoints.get(1).isKnown() : availPoints;
            assert availPoints.get(2).getAvailabilityType() == UNKNOWN : availPoints;
            assert !availPoints.get(2).isKnown() : availPoints;
            assert availPoints.get(3).getAvailabilityType() == UNKNOWN : availPoints;
            assert !availPoints.get(3).isKnown() : availPoints;
            assert availPoints.get(4).getAvailabilityType() == UNKNOWN : availPoints;
            assert !availPoints.get(4).isKnown() : availPoints;
            assert availPoints.get(5).getAvailabilityType() == UP : availPoints;
            assert availPoints.get(5).isKnown() : availPoints;
            assert availPoints.get(6).getAvailabilityType() == UP : availPoints;
            assert availPoints.get(7).getAvailabilityType() == UP : availPoints;
            assert availPoints.get(8).getAvailabilityType() == UP : availPoints;
            assert availPoints.get(9).getAvailabilityType() == UP : availPoints;

            report = new AvailabilityReport(false, theAgent.getName()); // 70000
            report.setEnablementReport(true); // simulate a real disable
            report.addAvailability(new Availability(theResource, (startMillis + 10000L), DISABLED));
            availabilityManager.mergeAvailabilityReport(report);
            // UNKNOWN(0) --> UP(60000) --> DISABLED(70000) -->           

            // before setting other avails, must end disable with enablement report to unknown
            report = new AvailabilityReport(false, theAgent.getName()); // 75000
            report.setEnablementReport(true);
            report.addAvailability(new Availability(theResource, (startMillis + 15000L), UNKNOWN));
            availabilityManager.mergeAvailabilityReport(report);
            // UNKNOWN(0) --> UP(60000) --> DISABLED(70000) --> UNKNOWN(75000) -->           

            report = new AvailabilityReport(false, theAgent.getName()); // 80000
            report.addAvailability(new Availability(theResource, (startMillis + 20000L), UP));
            availabilityManager.mergeAvailabilityReport(report);
            // UNKNOWN(0) --> UP(60000) --> DISABLED(70000) --> UNKNOWN(75000) --> UP(80000)           

            report = new AvailabilityReport(false, theAgent.getName()); // 90000
            report.addAvailability(new Availability(theResource, (startMillis + 30000L), DOWN));
            availabilityManager.mergeAvailabilityReport(report);
            // UNKNOWN(0) --> UP(60000) --> DISABLED(70000) --> UNKNOWN(75000) --> UP(80000) --> DOWN(90000) -->           

            availPoints = availabilityManager.findAvailabilitiesForResource(overlord, theResource.getId(),
                startMillis - 15000, startMillis + 35000, 5, false); // 45000 - 95000
View Full Code Here

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

            setupResource();
            commitAndClose();

            // add a report that says the resource was up 20 minutes ago
            Availability avail = new Availability(theResource, (System.currentTimeMillis() - 12000000), UP);
            AvailabilityReport report = new AvailabilityReport(false, theAgent.getName());
            report.addAvailability(avail);
            // UNKNOWN(0) -->            
            availabilityManager.mergeAvailabilityReport(report);
            // UNKNOWN(0) --> UP(-12000000) -->           
            assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId()) == UP;
View Full Code Here

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

                + (System.currentTimeMillis() - start) + "ms");

            // add a report that says the resources are now up or disabled- the report will add one avail for each
            // resource
            Thread.sleep(500);
            AvailabilityReport upReport = new AvailabilityReport(false, theAgent.getName());
            AvailabilityReport disabledReport = new AvailabilityReport(false, theAgent.getName());
            disabledReport.setEnablementReport(true);
            int resNum = 0;
            for (Resource resource : allResources) {
                if (resNum++ <= 80) {
                    upReport.addAvailability(new Availability(resource, UP));
                } else {
                    disabledReport.addAvailability(new Availability(resource, DISABLED));
                }
            }

            start = System.currentTimeMillis();
            availabilityManager.mergeAvailabilityReport(upReport);
View Full Code Here

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

            Availability avail;
            long now = System.currentTimeMillis();

            // add a report that says the resource is down
            avail = new Availability(theResource, DOWN);
            AvailabilityReport report = new AvailabilityReport(false, theAgent.getName());
            report.addAvailability(avail);
            availabilityManager.mergeAvailabilityReport(report);

            // now pretend the agent sent us a report from a previous time period - should insert this in the past
            avail = new Availability(theResource, (now - 600000), UP);
            report = new AvailabilityReport(false, theAgent.getName());
            report.addAvailability(avail);
            availabilityManager.mergeAvailabilityReport(report);
            assert getPointInTime(new Date(avail.getStartTime() - 2)) == UNKNOWN;
            assert getPointInTime(new Date(avail.getStartTime())) == UP;
            assert getPointInTime(new Date(avail.getStartTime() + 2)) == UP;

            // it's still down though - since we've received a more recent report saying it was down
            assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId()) == DOWN;

            // now pretend the agent sent us reports from inbetween our existing time periods
            // this UP record combines with the UP we added previously
            avail = new Availability(theResource, (now - 300000), UP);
            report = new AvailabilityReport(false, theAgent.getName());
            report.addAvailability(avail);
            availabilityManager.mergeAvailabilityReport(report);
            assert getPointInTime(new Date(avail.getStartTime() - 2)) == UP;
            assert getPointInTime(new Date(avail.getStartTime())) == UP;
            assert getPointInTime(new Date(avail.getStartTime() + 2)) == UP;

            // its still down though - since we've received a more recent report saying it was down
            assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId()) == DOWN;

            // this DOWN record combines with the current DOWN
            avail = new Availability(theResource, (now - 100000), DOWN);
            report = new AvailabilityReport(false, theAgent.getName());
            report.addAvailability(avail);
            availabilityManager.mergeAvailabilityReport(report);
            assert getPointInTime(new Date(avail.getStartTime() - 2)) == UP;
            assert getPointInTime(new Date(avail.getStartTime())) == DOWN;
            assert getPointInTime(new Date(avail.getStartTime() + 2)) == DOWN;

            // this DOWN record is between the two UPs we added earlier. However, because we are RLE,
            // we actually lost the information that we had an UP at both -60000 and -30000.  We just
            // have a RLE interval of UP starting at -60000.  This new DOWN record will add a new row
            // that will indicate we were only UP from -60000 to -45000 and DOWN thereafter.  This is
            // an odd test and probably will never occur in the wild (why would an agent tell us
            // we were one status in the past but another status further back in the past?)
            avail = new Availability(theResource, (now - 450000), DOWN);
            report = new AvailabilityReport(false, theAgent.getName());
            report.addAvailability(avail);
            availabilityManager.mergeAvailabilityReport(report);
            assert getPointInTime(new Date(avail.getStartTime() - 2)) == UP;
            assert getPointInTime(new Date(avail.getStartTime())) == DOWN;
            assert getPointInTime(new Date(avail.getStartTime() + 2)) == DOWN;

            // its still down
            assert availabilityManager.getCurrentAvailabilityTypeForResource(overlord, theResource.getId()) == DOWN;

            // let's insert one in the very beginning that is the same type as the current first interval
            avail = new Availability(theResource, (now - 700000), UP);
            report = new AvailabilityReport(false, theAgent.getName());
            report.addAvailability(avail);
            availabilityManager.mergeAvailabilityReport(report);
            assert getPointInTime(new Date(avail.getStartTime() - 2)) == UNKNOWN;
            assert getPointInTime(new Date(avail.getStartTime())) == UP;
            assert getPointInTime(new Date(avail.getStartTime() + 2)) == UP;
        } catch (Exception e) {
View Full Code Here

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

            String round = String.format(ROUND__FORMAT, MULTI);

            long t1 = System.currentTimeMillis() - (MULTI * MILLIS_APART);
            for (int i = 0; i < MULTI; i++) {

                AvailabilityReport report = new AvailabilityReport(agent.getName());
                for (Resource r : resources) {
                    AvailabilityType at = (i % 2 == 0) ? AvailabilityType.UP : AvailabilityType.DOWN;
                    Availability a = new Availability(r, (t1 + i * MILLIS_APART), at);
                    report.addAvailability(a);
                }
                startTiming(round);
                availabilityManager.mergeAvailabilityReport(report);
                endTiming(round);
            }
View Full Code Here

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

            String round = String.format(ROUND__FORMAT, MULTI);

            long t1 = System.currentTimeMillis() - (MULTI * MILLIS_APART);
            for (int i = 0; i < MULTI; i++) {

                AvailabilityReport report = new AvailabilityReport(agent.getName());
                for (Resource r : resources) {
                    int rand = (int) (Math.random() * 2);
                    AvailabilityType at = (rand == 1) ? AvailabilityType.UP : AvailabilityType.DOWN;
                    Availability a = new Availability(r, (t1 + i * MILLIS_APART), at);
                    report.addAvailability(a);
                }
                startTiming(round);
                availabilityManager.mergeAvailabilityReport(report);
                endTiming(round);
            }
View Full Code Here

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

            String round = String.format(ROUND__FORMAT, MULTI);

            long t1 = System.currentTimeMillis() - (MULTI * MILLIS_APART);
            for (int i = 0; i < MULTI; i++) {

                AvailabilityReport report = new AvailabilityReport(agent.getName());
                for (Resource r : resources) {
                    AvailabilityType at = AvailabilityType.UP;
                    Availability a = new Availability(r, (t1 + i * MILLIS_APART), at);
                    report.addAvailability(a);
                }
                startTiming(round);
                availabilityManager.mergeAvailabilityReport(report);
                endTiming(round);
            }
View Full Code Here

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

            String round = String.format(ROUND__FORMAT, MULTI);

            long t1 = System.currentTimeMillis() - (MULTI * MILLIS_APART);
            for (int i = 0; i < MULTI; i++) {

                AvailabilityReport report = new AvailabilityReport(agent.getName());
                for (Resource r : resources) {
                    AvailabilityType at = (i % 2 == 0) ? AvailabilityType.UP : AvailabilityType.DOWN;
                    Availability a = new Availability(r, (t1 + i * MILLIS_APART), at);
                    report.addAvailability(a);
                }
                startTiming(round);
                availabilityManager.mergeAvailabilityReport(report);
                endTiming(round);
            }
View Full Code Here

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

    @Override
    @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
    public void setResourceAvailabilities(Map<Agent, int[]> map, AvailabilityType avail) {
        long now = System.currentTimeMillis();
        for (Agent agent : map.keySet()) {
            AvailabilityReport report = new AvailabilityReport(true, null);
            report.setServerSideReport(true);
            for (int resourceId : map.get(agent)) {
                report.addAvailability(new Datum(resourceId, avail, now));
            }
            AvailabilityReportSerializer.getSingleton().lock(agent.getName());
            try {
                this.availabilityManager.mergeAvailabilityReport(report);
            } finally {
View Full Code Here

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

    }

    public OperationResult executeAvailabilityScan(Boolean changesOnly) {
        boolean changes = (changesOnly != null) ? changesOnly.booleanValue() : false;

        AvailabilityReport report;
        InventoryManager inventoryManager = PluginContainer.getInstance().getInventoryManager();

        ClassLoader originalCL = Thread.currentThread().getContextClassLoader();
        try {
            Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
            report = inventoryManager.executeAvailabilityScanImmediately(changes);
        } finally {
            Thread.currentThread().setContextClassLoader(originalCL);
        }

        OperationResult opResult = new OperationResult();
        Configuration complexResults = opResult.getComplexResults();

        PropertyList list = new PropertyList("resourceAvailabilities");
        complexResults.put(list);

        String agentName;
        Boolean changesOnlyFromReport;

        if (report != null) {
            agentName = report.getAgentName();
            changesOnlyFromReport = Boolean.valueOf(report.isChangesOnlyReport());

            List<AvailabilityReport.Datum> avails = report.getResourceAvailability();

            if (avails.size() > 0) {
                for (AvailabilityReport.Datum avail : avails) {
                    boolean isUp = avail.getAvailabilityType() == AvailabilityType.UP;
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.