本文整理汇总了Java中org.rhq.core.domain.measurement.MeasurementScheduleRequest.getDataType方法的典型用法代码示例。如果您正苦于以下问题:Java MeasurementScheduleRequest.getDataType方法的具体用法?Java MeasurementScheduleRequest.getDataType怎么用?Java MeasurementScheduleRequest.getDataType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rhq.core.domain.measurement.MeasurementScheduleRequest
的用法示例。
在下文中一共展示了MeasurementScheduleRequest.getDataType方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getValues
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
@Override
public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> msrs) throws Exception {
if (map.isEmpty())
getAvailability();
for (Iterator<MeasurementScheduleRequest> i = msrs.iterator(); i.hasNext(); ) {
MeasurementScheduleRequest msr = i.next();
Object o = map.get(msr.getName());
if (o != null) {
if (msr.getDataType() == DataType.MEASUREMENT) {
mr.addData(new MeasurementDataNumeric(msr, (Double)o));
} else {
mr.addData(new MeasurementDataTrait(msr, o.toString()));
}
}
}
}
示例2: getValues
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
@Override
public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> msr) throws Exception {
getAvailability(); // loads stats
for (MeasurementScheduleRequest r : msr) {
String name = r.getName();
Object val = stats.get(name);
if (val == null) {
continue;
}
if (r.getDataType() == DataType.MEASUREMENT) {
Number n;
if (name.endsWith("WindowId")) {
n = AppComponent.windowId(val);
} else {
n = Double.parseDouble(val.toString());
}
mr.addData(new MeasurementDataNumeric(r, n.doubleValue()));
} else {
mr.addData(new MeasurementDataTrait(r, val.toString()));
}
}
}
示例3: getValues
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
@Override
public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> msrs) throws Exception {
getAvailability();
for (MeasurementScheduleRequest msr : msrs) {
String s = info.getProperty(msr.getName());
if (s != null) {
if (msr.getDataType() == DataType.TRAIT) {
mr.addData(new MeasurementDataTrait(msr, s));
} else {
mr.addData(new MeasurementDataNumeric(msr, Double.parseDouble(s)));
}
} else {
log.warn("not found " + msr.getName());
}
}
}
示例4: getValues
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
public void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests) {
List<EmsBean> beans = parent.getEmsConnection().queryBeans(objectName);
log.debug("found " + beans.size());
for (MeasurementScheduleRequest request : requests) {
String name = request.getName();
double sum = 0;
for (EmsBean bean : beans) {
EmsAttribute attr = bean.getAttribute(name);
if (attr == null || attr.getValue() == null) {
log.error(name + " not found");
continue;
}
Object value = attr.getValue();
if (value instanceof Number) {
sum += ((Number)value).doubleValue();
}
}
if (request.getDataType() == DataType.MEASUREMENT) {
report.addData(new MeasurementDataNumeric(request, sum));
}
}
}
示例5: getValues
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
@Override
public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> msrs) throws Exception {
getAvailability();
for (MeasurementScheduleRequest msr : msrs) {
Object o = stats.get(msr.getName());
if (o != null) {
if (msr.getDataType() == DataType.TRAIT) {
mr.addData(new MeasurementDataTrait(msr, o.toString()));
} else {
Number n = (Number)o;
mr.addData(new MeasurementDataNumeric(msr, n.doubleValue()));
}
} else {
log.warn("not found " + msr.getName());
}
}
}
示例6: getValues
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
@Override
public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> msrs) throws Exception {
getAvailability();
for (MeasurementScheduleRequest msr : msrs) {
Object o = collection.getStats().get(msr.getName());
if (o != null) {
if (msr.getDataType() == DataType.TRAIT) {
mr.addData(new MeasurementDataTrait(msr, o.toString()));
} else {
Number n = (Number)o;
mr.addData(new MeasurementDataNumeric(msr, n.doubleValue()));
}
} else {
log.warn("not found " + msr.getName());
}
}
}
示例7: addData
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
public static void addData(MeasurementReport report, MeasurementScheduleRequest request, Object value) {
switch (request.getDataType()) {
case MEASUREMENT:
Double doubleValue;
if (value instanceof Double) {
doubleValue = (Double)value;
} else if (value instanceof Number) {
doubleValue = Double.valueOf(((Number)value).doubleValue());
} else {
log.error("Type " + value.getClass() + " not support for numeric measurements");
break;
}
if (log.isDebugEnabled()) {
log.debug("Adding (numeric) measurement for " + request.getName() + "; value=" + value);
}
report.addData(new MeasurementDataNumeric(request, doubleValue));
break;
case TRAIT:
if (log.isDebugEnabled()) {
log.debug("Adding measurement (trait) for " + request.getName() + "; value=" + value);
}
report.addData(new MeasurementDataTrait(request, value == null ? null : value.toString()));
break;
default:
log.error("Data type " + request.getDataType() + " not supported");
}
}
示例8: getValues
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
@Override
public void getValues(MeasurementReport mr, Set<MeasurementScheduleRequest> msrs) throws Exception {
getAvailability();
for (MeasurementScheduleRequest msr : msrs) {
String name = msr.getName();
if (name.equals(GET_RATIO)) {
String ms = info.get(GET_MISSES);
String hs = info.get(GET_HITS);
if (ms == null || hs == null)
continue;
get_misses = Long.parseLong(ms);
get_hits = Long.parseLong(hs);
double hd = get_hits - get_hits2;
double md = get_misses - get_misses2;
get_misses2 = get_misses;
get_hits2 = get_hits;
if (md + hd == 0)
continue; // avoid NaN
double d = hd / (md + hd);
if (d < 0)
continue; // stats were reset?
mr.addData(new MeasurementDataNumeric(msr, d));
continue;
}
String s = info.get(name);
if (s != null) {
if (msr.getDataType() == DataType.TRAIT) {
mr.addData(new MeasurementDataTrait(msr, s));
} else {
mr.addData(new MeasurementDataNumeric(msr, Double.parseDouble(s)));
}
} else {
log.warn("stat not found " + name);
}
}
}
示例9: asMeasurement
import org.rhq.core.domain.measurement.MeasurementScheduleRequest; //导入方法依赖的package包/类
/**
* Converts an SNMP variable into an RHQ measurement value.
* This includes mapping integer values into string constants,
* converting strings to doubles, etc.
*
* @param request measurement request
* @param variable SNMP variable
* @return data as a trait or numeric (or complex)
*/
private MeasurementData asMeasurement(MeasurementScheduleRequest request, Variable variable) {
if (variable == null)
throw new NullPointerException("variable");
if (request == null)
throw new NullPointerException("request");
DataType dataType = request.getDataType();
String name = request.getName();
if (variable instanceof Integer32) {
int i = ((Integer32)variable).toInt();
Map<Integer, String> mapping = index.getMapping(name);
if (mapping != null && !mapping.isEmpty()) {
return new MeasurementDataTrait(request, mapping.get(i));
}
}
if (dataType == DataType.TRAIT) {
return new MeasurementDataTrait(request, variable.toString());
}
if (variable instanceof OctetString && dataType == DataType.MEASUREMENT) {
// interpret as String
return new MeasurementDataNumeric(request, new Double(variable.toString()));
}
if (variable instanceof TimeTicks) {
long ms = ((TimeTicks)variable).toMilliseconds();
return new MeasurementDataNumeric(request, (double)ms);
}
return new MeasurementDataNumeric(request, (double)variable.toLong());
}