Exemplo n.º 1
0
 /**
  * Return availability of this resource
  *
  * @see org.rhq.core.pluginapi.inventory.ResourceComponent#getAvailability()
  */
 @Override
 public AvailabilityType getAvailability() {
   boolean trace = log.isTraceEnabled();
   EmsConnection conn = getConnection();
   try {
     conn.refresh();
     EmsBean bean = queryCacheBean();
     if (bean != null && bean.getAttribute("CacheStatus").getValue().equals("RUNNING")) {
       bean.refreshAttributes();
       if (trace)
         log.trace(
             "Cache "
                 + cacheName
                 + " within "
                 + cacheManagerName
                 + " cache manager is running and attributes could be refreshed, so it's up.");
       return AvailabilityType.UP;
     }
     if (trace)
       log.trace(
           "Cache status for "
               + cacheName
               + " within "
               + cacheManagerName
               + " cache manager is anything other than running, so it's down.");
     return AvailabilityType.DOWN;
   } catch (Exception e) {
     if (trace)
       log.trace("There was an exception checking availability, so cache status is down.", e);
     return AvailabilityType.DOWN;
   }
 }
Exemplo n.º 2
0
 /**
  * Gather measurement data
  *
  * @see
  *     org.rhq.core.pluginapi.measurement.MeasurementFacet#getValues(org.rhq.core.domain.measurement.MeasurementReport,
  *     java.util.Set)
  */
 @Override
 public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> metrics) {
   boolean trace = log.isTraceEnabled();
   if (trace) log.trace("Get values metrics");
   for (MeasurementScheduleRequest req : metrics) {
     if (trace) log.trace("Inspect metric " + req);
     String metric = req.getName();
     try {
       EmsBean bean = queryComponentBean(metric);
       if (bean != null) {
         if (trace) log.trace("Retrieved mbean with name " + bean.getBeanName());
         bean.refreshAttributes();
         String attName = metric.substring(metric.indexOf(".") + 1);
         EmsAttribute att = bean.getAttribute(attName);
         // Attribute values are of various data types
         if (att != null) {
           Object o = att.getValue();
           Class<?> attrType = att.getTypeClass();
           DataType type = req.getDataType();
           if (type == DataType.MEASUREMENT) {
             if (o != null) {
               MeasurementDataNumeric res = constructNumericMeasure(attrType, o, req);
               if (res != null) report.addData(res);
             } else {
               if (log.isDebugEnabled())
                 log.debug("Metric (" + req.getName() + ") has null value, do not add to report");
             }
           } else if (type == DataType.TRAIT) {
             String value = (String) o;
             if (trace) log.trace("Metric (" + req.getName() + ") is trait with value " + value);
             MeasurementDataTrait res = new MeasurementDataTrait(req, value);
             report.addData(res);
           }
         } else {
           if (log.isWarnEnabled()) {
             log.warn("Attribute " + attName + " not found");
           }
         }
       }
     } catch (Exception e) {
       if (log.isWarnEnabled()) {
         log.warn("getValues failed for " + metric, e);
       }
     }
   }
 }