if (resourceId == 0) {
System.err.println("No resource set");
return;
}
MeasurementManager mm = pc.getMeasurementManager();
if (tokens[1].equals("-list")) {
ResourceType rt = getTypeForResourceId();
Set<MeasurementDefinition> defs = rt.getMetricDefinitions();
if (defs == null || defs.isEmpty()) {
System.out.println("Resource has no metrics");
return;
}
for (MeasurementDefinition def : defs) {
System.out.println(def.getName() + " : " + def.getDataType() + ", " + def.getDescription());
}
return;
}
if (tokens.length < 3) {
System.err.println("measure needs at least two parameters");
return;
}
DataType dataType = getDataType(tokens[1]);
if (dataType == null) {
System.err.println("Unknown DataType " + tokens[1]);
System.err.println("Valid ones are measurement, trait, calltime, complex");
}
String[] metricNames = new String[tokens.length - 2];
System.arraycopy(tokens, 2, metricNames, 0, tokens.length - 2);
Set<MeasurementScheduleRequest> requests = new HashSet<MeasurementScheduleRequest>();
for (String metric : metricNames) {
requests.add(new MeasurementScheduleRequest(MeasurementScheduleRequest.NO_SCHEDULE_ID, metric, 0, true,
dataType));
}
Set<MeasurementData> dataset = mm.getRealTimeMeasurementValue(resourceId, requests);
if (dataset == null) {
System.err.println("No data returned");
return;
}
for (MeasurementData data : dataset) {