Package org.rhq.core.pluginapi.measurement

Examples of org.rhq.core.pluginapi.measurement.MeasurementFacet


    public Set<MeasurementData> getRealTimeMeasurementValue(int resourceId, Set<MeasurementScheduleRequest> requests) {
        if (requests.size() == 0) {
            // There's no need to even call getValues() on the ResourceComponent if the list of metric names is empty.
            return Collections.emptySet();
        }
        MeasurementFacet measurementFacet;
        ResourceContainer resourceContainer = inventoryManager.getResourceContainer(resourceId);
        if (resourceContainer == null) {
            LOG.warn("Can not get resource container for resource with id " + resourceId);
            return Collections.emptySet();
        }
        Resource resource = resourceContainer.getResource();
        ResourceType resourceType = resource.getResourceType();
        if (resourceType.getMetricDefinitions().isEmpty())
            return Collections.emptySet();

        try {
            measurementFacet = ComponentUtil.getComponent(resourceId, MeasurementFacet.class, FacetLockType.READ,
                FACET_METHOD_TIMEOUT, true, true, true);
        } catch (Exception e) {
            LOG.warn("Cannot get measurement facet for Resource [" + resourceId + "]. Cause: " + e);
            return Collections.emptySet();
        }

        MeasurementReport report = new MeasurementReport();
        for (MeasurementScheduleRequest request : requests) {
            request.setEnabled(true);
        }

        try {
            measurementFacet.getValues(report, Collections.unmodifiableSet(requests));
        } catch (Throwable t) {
            LOG.error("Could not get measurement values", t);
            return Collections.emptySet();
        }
View Full Code Here


                    if (log.isDebugEnabled()) {
                        log.debug("Measurements not collected for inactive resource component: "
                            + container.getResource());
                    }
                } else {
                    MeasurementFacet measurementComponent = ComponentUtil
                        .getComponent(resourceId, MeasurementFacet.class, FacetLockType.READ,
                            MeasurementManager.FACET_METHOD_TIMEOUT, true, true, true);

                    if (log.isDebugEnabled()) {
                        scheduleHistory.addRequests(requests);
View Full Code Here

        ResourceContainer resourceContainer = this.pluginContainer.getInventoryManager().getResourceContainer(resource);
        long timeoutMillis = 5000;
        if (resourceContainer.getResourceComponentState() != ResourceContainer.ResourceComponentState.STARTED) {
            throw new IllegalStateException("Resource component for " + resource + " has not yet been started.");
        }
        MeasurementFacet measurementFacet = resourceContainer.createResourceComponentProxy(MeasurementFacet.class,
            FacetLockType.READ, timeoutMillis, false, false, false);
        MeasurementReport report = new MeasurementReport();
        MeasurementScheduleRequest request = new MeasurementScheduleRequest(-1, metricName, -1, true,
            measurementDefinition.getDataType(), measurementDefinition.getRawNumericType());
        Set<MeasurementScheduleRequest> requests = new HashSet<MeasurementScheduleRequest>();
        requests.add(request);
        try {
            measurementFacet.getValues(report, requests);
        } catch (Exception e) {
            System.out.println("====== Error occurred during collection of metric [" + metricName + "] on " + resource
                + ": " + e);
            throw new RuntimeException("Error occurred during collection of metric [" + metricName + "] on " + resource
                + ": " + e);
View Full Code Here

    private void testRuntimeResourceMeasurements(RuntimeServiceType runtimeServiceType) throws Exception {
        Set<Resource> resources = getChildResourcesOfType(getDeploymentResource(),
            runtimeServiceType.getServiceTypeName());
        for (Resource resource : resources) {
            MeasurementFacet measurementFacet = getMeasurementFacet(resource);
            // TODO (jshaughn) see why we get into this occasionally
            System.out.println("--->>> " + resource + " MeasurementFacet=" + measurementFacet);
            if (null == measurementFacet)
                continue;
            MeasurementReport report = new MeasurementReport();
            Set<MeasurementScheduleRequest> measurementScheduleRequests = getMeasurementScheduleRequests(resource);
            measurementFacet.getValues(report, measurementScheduleRequests);
            assertEquals(report.getCallTimeData().size(), 0, runtimeServiceType.getServiceTypeName()
                + ": no calltime data was requested");
            assertEquals(
                report.getNumericData().size() + report.getTraitData().size(),
                measurementScheduleRequests.size(),
View Full Code Here

    @Test(dependsOnMethods = "testServiceDiscovery")
    public void testMeasurement() throws Exception {
        Set<Resource> childResources = getChildResourcesOfType(jmxServerResource, OPERATING_SYSTEM_RESOURCE_TYPE);
        assertEquals(childResources.size(), 1, String.valueOf(childResources));

        MeasurementFacet measurementFacet = getResourceComponentFacet(childResources.iterator().next(),
            MeasurementFacet.class);
        Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
        metricList.add(new MeasurementScheduleRequest(1, "CommittedVirtualMemorySize", 1000, true, MEASUREMENT));

        MeasurementReport report = new MeasurementReport();
        measurementFacet.getValues(report, metricList);
        Map<String, Object> metricsData = getMetricsData(report);

        assertTrue(getMetric(metricsData, "CommittedVirtualMemorySize") > 0);
    }
View Full Code Here

        assertEquals(webRuntimeResources.size(), 1, "Found more than one Web Runtime resource: " + webRuntimeResources);

        Resource webRuntimeResource = webRuntimeResources.iterator().next();
        ResourceContainer webRuntimeResourceContainer = pluginContainer.getInventoryManager().getResourceContainer(
            webRuntimeResource);
        MeasurementFacet measurementFacet = webRuntimeResourceContainer.createResourceComponentProxy(
            MeasurementFacet.class, FacetLockType.READ, SECONDS.toMillis(5), false, false, false);
        MeasurementReport report = new MeasurementReport();
        Set<MeasurementScheduleRequest> measurementScheduleRequests = getMeasurementScheduleRequests(webRuntimeResource);
        measurementFacet.getValues(report, measurementScheduleRequests);
        assertEquals(report.getCallTimeData().size(), 0, "No calltime data was requested");
        assertTrue(
            report.getNumericData().size() + report.getTraitData().size() == measurementScheduleRequests.size(),
            "Some requested measurements are missing: "
                + getMissingMeasurements(measurementScheduleRequests, report.getNumericData(), report.getTraitData()));
View Full Code Here

    public void testMeasurement() throws Exception {
        for (Resource jmxServer : jmxServers) {
            Set<Resource> childResources = getChildResourcesOfType(jmxServer, OPERATING_SYSTEM_RESOURCE_TYPE);
            assertEquals(childResources.size(), 1, String.valueOf(childResources));

            MeasurementFacet measurementFacet = getResourceComponentFacet(childResources.iterator().next(),
                MeasurementFacet.class);
            Set<MeasurementScheduleRequest> metricList = new HashSet<MeasurementScheduleRequest>();
            metricList.add(new MeasurementScheduleRequest(1, "CommittedVirtualMemorySize", 1000, true, MEASUREMENT));

            MeasurementReport report = new MeasurementReport();
            measurementFacet.getValues(report, metricList);
            Map<String, Object> metricsData = getMetricsData(report);

            assertTrue(getMetric(metricsData, "CommittedVirtualMemorySize") > 0);
        }
    }
View Full Code Here

        if (supportsFacet(MeasurementFacet.class)) {
            Set<MeasurementDefinition> metricDefinitions = getResourceType().getMetricDefinitions();
            Set<Resource> resources = getResources();
            for (Resource resource : resources) {
                System.out.println("Validating metrics for " + resource + "...");
                MeasurementFacet measurementFacet = ComponentUtil.getComponent(resource.getId(),
                    MeasurementFacet.class, FacetLockType.READ, MEASUREMENT_FACET_METHOD_TIMEOUT, true, true, true);
                for (MeasurementDefinition metricDefinition : metricDefinitions) {
                    String name = metricDefinition.getName();
                    try {
                        DataType dataType = metricDefinition.getDataType();
                        if (dataType == DataType.MEASUREMENT || metricDefinition.getDataType() == DataType.TRAIT) {
                            MeasurementReport report = new MeasurementReport();
                            Set<MeasurementScheduleRequest> requests = new HashSet<MeasurementScheduleRequest>();
                            MeasurementScheduleRequest request = new MeasurementScheduleRequest(1, metricDefinition
                                .getName(), 0, true, metricDefinition.getDataType());
                            requests.add(request);
                            measurementFacet.getValues(report, requests);
                            if (dataType == DataType.MEASUREMENT) {
                                assert report.getNumericData().isEmpty() || report.getNumericData().size() == 1;
                                assert report.getTraitData().isEmpty();
                                assert report.getCallTimeData().isEmpty();
                                MeasurementDataNumeric dataNumeric = (report.getNumericData().isEmpty()) ? null
View Full Code Here

  }

  public static String getMetricValue(Resource resource, String metricName)
      throws Exception {

    MeasurementFacet measurementFacet = ComponentUtil
        .getComponent(resource.getId(), MeasurementFacet.class,
            FacetLockType.READ,
            CacheComponentTest.MEASUREMENT_FACET_METHOD_TIMEOUT,
            true, true, true);
    ResourceType resourceType = resource.getResourceType();
View Full Code Here

    Set<Resource> resources = TestHelper.getResources(cacheResourceType);

    for (Resource resource : resources) {
      log.info("Validating metrics for " + resource + "...");

      MeasurementFacet measurementFacet = ComponentUtil.getComponent(
          resource.getId(), MeasurementFacet.class,
          FacetLockType.READ, MEASUREMENT_FACET_METHOD_TIMEOUT, true,
          true, true);
      EmsBean relatedBean = connection.getBean(resource.getResourceKey());
View Full Code Here

TOP

Related Classes of org.rhq.core.pluginapi.measurement.MeasurementFacet

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.