Package org.rhq.core.domain.measurement

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


            // prime the pump by getting the first avail synchronously
            System.out.println("~~~AVAILABILITY PROXY CALL #" + 0 + " at " + new Date());
            AvailabilityType firstAvail = ap.getAvailability();
            assert UP.equals(firstAvail) : "Can't even get our first avail correctly: " + firstAvail;
            Mockito.when(resourceContainer.getAvailability()).thenReturn(
                new Availability(new Resource(1), AvailabilityType.UP)); // last avail is UP and will stay as UP

            // make several calls to availProxy.getAvailability() in quick succession
            final int numCalls = 15;
            final Hashtable<String, AvailabilityType> availResults = new Hashtable<String, AvailabilityType>(numCalls);
            final Hashtable<String, Date> dateResults = new Hashtable<String, Date>(numCalls);
View Full Code Here


        }

        if (!disabledResource) {
            resourceCounter.tallyResource(resource);

            Availability avail = resourceContainer.getAvailability();
            AvailabilityType availType = null;
            if (avail != null) {
                availType = avail.getAvailabilityType();
            }
            String availString = (availType == null) ? "UNKNOWN" : availType.toString();

            Set<ResourcePackageDetails> installedPackages = resourceContainer.getInstalledPackages();
            int installedPackageCount = installedPackages == null ? 0 : installedPackages.size();
View Full Code Here

        inventoryManager.requestAvailabilityCheck(resource);
    }

    @Override
    public AvailabilityType getLastReportedAvailability() {
        Availability avail = inventoryManager.getAvailabilityIfKnown(resource);
        return (null != avail) ? avail.getAvailabilityType() : null;
    }
View Full Code Here

    @Path("/{id}/availability")
    @ApiError(code = 404, reason = NO_RESOURCE_FOR_ID)
    @ApiOperation(value = "Return the current availability for the passed resource", responseClass = "AvailabilityRest")
    public Response getAvailability(@ApiParam("Id of the resource to query") @PathParam("id") int resourceId, @Context HttpHeaders headers) {

        Availability avail = availMgr.getCurrentAvailabilityForResource(caller, resourceId);
        AvailabilityRest availabilityRest;
        if (avail.getAvailabilityType() != null)
            availabilityRest = new AvailabilityRest(avail.getAvailabilityType(), avail.getStartTime(), avail
                .getResource().getId());
        else
            availabilityRest = new AvailabilityRest(avail.getStartTime(), resourceId);

        MediaType mediaType = headers.getAcceptableMediaTypes().get(0);
        Response.ResponseBuilder builder;

        if (mediaType.equals(MediaType.TEXT_HTML_TYPE)) {
View Full Code Here

        }

        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

        Resource jonDs = null;//findService("RHQDS", SERVER_JON, platform);
        Resource defaultDs = null;//findService("DefaultDS", SERVER_JON, platform);

        DiscoveryAgentService discoveryService = PluginContainer.getInstance().getDiscoveryAgentService();

        Availability availability;

        availability = discoveryService.getAvailability(jonDs);
        assert availability != null : "Availability was returned as null";
        assert availability.getResource().getId() == jonDs.getId() : "Incorrect resource ID associated with availability";
        assert availability.getAvailabilityType() == AvailabilityType.UP : "Mock default value for availability was set incorrectly";

        availability = discoveryService.getAvailability(defaultDs);
        assert availability != null : "Availability was returned as null";
        assert availability.getResource().getId() == defaultDs.getId() : "Incorrect resource ID associated with availability";
        assert availability.getAvailabilityType() == AvailabilityType.DOWN : "Mock did not set availability to down correctly";

    }
View Full Code Here

    /**
     * Pass in a series of availability type/start time pairs. The start time
     * must be in seconds - this method will convert that to a proper date.
     */
    private List<Availability> list(Object... objs) {
        Availability previousAvail = null;
        List<Availability> a = new ArrayList<Availability>();
        for (int i = 0; i < objs.length; i = i + 2) {
            Long startTime = new Long(((Number) objs[i + 1]).longValue() * 1000L);
            Availability newAvail = new Availability(res, startTime, (AvailabilityType) objs[i]);
            if (previousAvail != null) {
                previousAvail.setEndTime(startTime);
            }
            previousAvail = newAvail;
            a.add(newAvail);
View Full Code Here

            assertResults(entityManager, fiveMinutesAgo, 0);
            assertCount(entityManager, fiveMinutesAgo, 0);

            ResourceAvailability resourceAvail = new ResourceAvailability(platform, AvailabilityType.DOWN);
            entityManager.persist(resourceAvail);
            Availability avail = new Availability(platform, AvailabilityType.DOWN);
            entityManager.persist(avail);

            //commitAndBegin();
            results = assertResults(entityManager, fiveMinutesAgo, 1);
            assertCount(entityManager, fiveMinutesAgo, 1);
            assertComposite(results.get(0), platform, 0);
            assert results.get(0).getAvailabilityType() == AvailabilityType.DOWN;
            assertComposite(results.get(0), platform, 0);
            assert results.get(0).getAvailabilityType() == AvailabilityType.DOWN;

            ResourceAvailability resourceAvail2 = new ResourceAvailability(platform2, AvailabilityType.DOWN);
            entityManager.persist(resourceAvail2);
            Availability avail2 = new Availability(platform2, null, AvailabilityType.DOWN);
            entityManager.persist(avail2);

            //commitAndBegin();
            results = assertResults(entityManager, fiveMinutesAgo, 2);
            assertCount(entityManager, fiveMinutesAgo, 2);
View Full Code Here

                newResource.setUuid("" + new Random().nextInt());
                newResource.setAgent(theAgent);
                em.persist(newResource);
                resources.add(newResource);

                em.persist(new Availability(newResource, AvailabilityType.UP));
            }
        } finally {
            getTransactionManager().commit();
        }
View Full Code Here

        ResourceType resourceType = new ResourceType("fake platform", "fake plugin", ResourceCategory.PLATFORM, null);
        em.persist(resourceType);
        Resource platform = new Resource("org.jboss.on.TestPlatfor", "Fake Platform", resourceType);
        platform.setUuid(UUID.randomUUID().toString());
        em.persist(platform);
        Availability a = new Availability(platform, date.getTime(), AvailabilityType.UP);
        ids.add(platform.getId());
        Resource platform2 = new Resource("org.jboss.on.TestPlatform2", "Fake Platform2", resourceType);
        platform2.setUuid(UUID.randomUUID().toString());
        em.persist(platform2);
        Availability a2 = new Availability(platform2, date.getTime(), AvailabilityType.UP);
        ids.add(platform2.getId());
        Resource platform3 = new Resource("org.jboss.on.TestPlatform3", "Fake Platform3", resourceType);
        platform3.setUuid(UUID.randomUUID().toString());
        em.persist(platform3);
        Availability a3 = new Availability(platform3, date.getTime(), AvailabilityType.UP);
        ids.add(platform3.getId());
        em.persist(a);
        em.persist(a2);
        em.persist(a3);
        return ids;
View Full Code Here

TOP

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

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.