Package org.rhq.core.domain.measurement

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


                    {
                        // We can't figure out the context root for a stopped WAR.
                        continue;
                    }
                    String contextRoot = (contextPath.equals("/")) ? "/" : contextPath.substring(1);
                    MeasurementDataTrait trait = new MeasurementDataTrait(request, contextRoot);
                    report.addData(trait);
                }
                else if (metricName.equals(VIRTUAL_HOSTS_TRAIT))
                {
                    if (contextPath == null)
                    {
                        // We can't figure out the virtual hosts for a stopped WAR.
                        continue;
                    }
                    Set<String> virtualHosts = WebApplicationContextDiscoveryComponent.getVirtualHosts(contextPath,
                            managementView);
                    String value = "";
                    for (Iterator<String> iterator = virtualHosts.iterator(); iterator.hasNext();)
                    {
                        String virtualHost = iterator.next();
                        value += virtualHost;
                        if (iterator.hasNext())
                            value += ", ";
                    }
                    MeasurementDataTrait trait = new MeasurementDataTrait(request, value);
                    report.addData(trait);
                }
            }
            catch (Exception e)
            {
View Full Code Here


        boolean snmpPresent = snmpSession.ping();

        for (MeasurementScheduleRequest schedule : schedules) {
            String metricName = schedule.getName();
            if (metricName.equals(SERVER_BUILT_TRAIT)) {
                MeasurementDataTrait trait = new MeasurementDataTrait(schedule, this.binaryInfo.getBuilt());
                report.addData(trait);
            } else if (metricName.equals("rhq_avail_ping_time")) {
                if (availPingTime == -1)
                    continue; // Skip if we have no data
                MeasurementDataNumeric num = new MeasurementDataNumeric(schedule, (double) availPingTime);
View Full Code Here

             String metricName = convertStringToBMX(schedule.getName());
             if (LOG.isDebugEnabled()) {
                 LOG.debug("Collecting BMX metric [" + metricName + "]");
             }
             if (metricName.equals(SERVER_BUILT_TRAIT)) {
                 MeasurementDataTrait trait = new MeasurementDataTrait(schedule, this.binaryInfo.getBuilt());
                 report.addData(trait);
             } else if (metricName.equals("rhq_avail_ping_time")) {
                 if (availPingTime == -1)
                     continue; // Skip if we have no data
                 MeasurementDataNumeric num = new MeasurementDataNumeric(schedule, (double) availPingTime);
                 report.addData(num);
             } else if (values.containsKey(metricName)) {
                 if (schedule.getDataType()== DataType.TRAIT) {
                    String val = values.get(metricName);
                    MeasurementDataTrait mdt = new MeasurementDataTrait(schedule,val);
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("Collected BMX metric [" + metricName + "], value = " + val);
                    }
                    report.addData(mdt);
                 } else {
View Full Code Here

                    // looks like a port - strip off the leading "TCP protocol id" (i.e. "1.3.6.1.2.1.6.")...
                    stringValue = stringValue.substring(stringValue.lastIndexOf('.') + 1);
                }
            }

            MeasurementDataTrait trait = new MeasurementDataTrait(schedule, stringValue);
            report.addData(trait);
            break;
        }

        default: {
View Full Code Here

            MeasurementDataNumeric dataNumeric = new MeasurementDataNumeric(request,
                (Double) ((SimpleValueSupport) (compositeValue.get(metricName))).getValue());
            report.addData(dataNumeric);
        } else if (dataType.equals(DataType.TRAIT)) {
            //@todo break out the getting the value out of the ValueSupport object
            MeasurementDataTrait dataTrait = new MeasurementDataTrait(request,
                (String) ((SimpleValueSupport) (compositeValue.get(metricName))).getValue());
            report.addData(dataTrait);
        }
    }
View Full Code Here

            String name = request.getName();

            if (name.equals("partitionName")) {
                String partitionName = getPartitionName();
                if (partitionName != null) {
                    report.addData(new MeasurementDataTrait(request, partitionName));
                }
            } else {
                int delimIndex = name.lastIndexOf(':');
                String beanName = name.substring(0, delimIndex);
                String attributeName = name.substring(delimIndex + 1);
                try {
                    // Bean is cached by EMS, so no problem with getting the bean from the connection on each call
                    EmsConnection emsConnection = loadConnection();
                    EmsBean bean = emsConnection.getBean(beanName);
                    EmsAttribute attribute = bean.getAttribute(attributeName);

                    Object valueObject = attribute.refresh();
                    if (valueObject instanceof Number) {
                        Number value = (Number) valueObject;
                        report.addData(new MeasurementDataNumeric(request, value.doubleValue()));
                    } else {
                        report.addData(new MeasurementDataTrait(request, valueObject.toString()));
                    }
                } catch (Exception e) {
                    log.error("Failed to obtain measurement [" + name + "]", e);
                }
            }
View Full Code Here

        }
    }

    private MeasurementDataTrait getConnectionAvailable(MeasurementScheduleRequest request) {
        Result res = getASConnection().execute(new Operation("test-connection-in-pool", getAddress()));
        return new MeasurementDataTrait(request, String.valueOf(res.isSuccess()));
    }
View Full Code Here

                        displayValue = Arrays.deepToString((Object[]) value);
                    } else {
                        displayValue = String.valueOf(value);
                    }

                    report.addData(new MeasurementDataTrait(request, displayValue));
                }
            }
        }
    }
View Full Code Here

                Operation op = new ReadAttribute(address, "start-time");
                Result res = getASConnection().execute(op);

                if (res.isSuccess()) {
                    Long startTime = (Long) res.getResult();
                    MeasurementDataTrait data = new MeasurementDataTrait(request, new Date(startTime).toString());
                    report.addData(data);
                }
            } else if (request.getName().equals("multicastAddress")) {
                collectMulticastAddressTrait(report, request);
            } else {
                leftovers.add(request);
            }
        }

        // Now handle the skm (this could go into a common method with BaseServerComponent's impl.
        if (skmRequests.size() > 0) {
            Address address = new Address();
            ReadResource op = new ReadResource(address);
            op.includeRuntime(true);
            ComplexResult res = getASConnection().executeComplex(op);
            if (res.isSuccess()) {
                Map<String, Object> props = res.getResult();

                for (MeasurementScheduleRequest request : skmRequests) {
                    String requestName = request.getName();
                    String realName = requestName.substring(requestName.indexOf(':') + 1);
                    String val = null;
                    if (props.containsKey(realName)) {
                        val = getStringValue(props.get(realName));
                    }

                    if ("null".equals(val)) {
                        if (realName.equals("product-name")) {
                            val = "JBoss AS";
                        }
                        else if (realName.equals("product-version")) {
                            val = getStringValue(props.get("release-version"));
                        }
                        else if (getLog().isDebugEnabled()) {
                            getLog().debug("Value for " + realName + " was 'null' and no replacement found");
                        }
                    }
                    MeasurementDataTrait data = new MeasurementDataTrait(request, val);
                    report.addData(data);
                }
            } else if (getLog().isDebugEnabled()) {
                getLog().debug("getSKMRequests failed: " + res.getFailureDescription());
            }
View Full Code Here

                try {
                    Configuration parameters = new Configuration();
                    OperationResult result = invokeOperation(managedComponent, "testConnection", parameters);
                    PropertySimple resultProp = result.getComplexResults().getSimple("result");
                    boolean connectionAvailable = resultProp.getBooleanValue();
                    MeasurementDataTrait trait = new MeasurementDataTrait(request, connectionAvailable ? "yes" : "no");
                    report.addData(trait);
                } catch (Exception e) {
                    log.error("Failed to collect trait [" + metricName + "].", e);
                }
            } else {
View Full Code Here

TOP

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

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.