本文整理汇总了Java中org.onosproject.cpman.MetricsDatabase类的典型用法代码示例。如果您正苦于以下问题:Java MetricsDatabase类的具体用法?Java MetricsDatabase怎么用?Java MetricsDatabase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MetricsDatabase类属于org.onosproject.cpman包,在下文中一共展示了MetricsDatabase类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testMultipleMetrics
import org.onosproject.cpman.MetricsDatabase; //导入依赖的package包/类
/**
* Test multiple metrics update and query.
*/
@Test
public void testMultipleMetrics() {
MetricsDatabase multiMdb = new DefaultMetricsDatabase.Builder()
.withMetricName(MEMORY_METRIC)
.withResourceName(DEFAULT_RES)
.addMetricType(MEMORY_FREE_PERC)
.addMetricType(MEMORY_USED_PERC)
.build();
Map<String, Double> metrics = new HashMap<>();
metrics.putIfAbsent(MEMORY_FREE_PERC, 30D);
metrics.putIfAbsent(MEMORY_USED_PERC, 70D);
multiMdb.updateMetrics(metrics);
assertThat(30D, is(multiMdb.recentMetric(MEMORY_FREE_PERC)));
assertThat(70D, is(multiMdb.recentMetric(MEMORY_USED_PERC)));
}
示例2: genMDbBuilder
import org.onosproject.cpman.MetricsDatabase; //导入依赖的package包/类
/**
* Builds and returns metric database instance with given resource name,
* resource type and metric type.
*
* @param resourceName resource name
* @param resourceType resource type
* @param metricTypes metric type
* @return metric database instance
*/
private MetricsDatabase genMDbBuilder(String resourceName,
Type resourceType,
Set<ControlMetricType> metricTypes) {
MetricsDatabase.Builder builder = new DefaultMetricsDatabase.Builder();
builder.withMetricName(resourceType.toString());
builder.withResourceName(resourceName);
metricTypes.forEach(type -> builder.addMetricType(type.toString()));
return builder.build();
}
示例3: build
import org.onosproject.cpman.MetricsDatabase; //导入依赖的package包/类
@Override
public MetricsDatabase build() {
checkNotNull(metricName, METRIC_NAME_MSG);
checkNotNull(resourceName, RESOURCE_NAME_MSG);
checkArgument(!dsDefs.isEmpty(), METRIC_TYPE_MSG);
// define the resolution of monitored metrics
rrdDef = new RrdDef(DB_PATH + SPLITTER + metricName +
SPLITTER + resourceName, RESOLUTION_IN_SECOND);
try {
DsDef[] dsDefArray = new DsDef[dsDefs.size()];
IntStream.range(0, dsDefs.size()).forEach(i -> dsDefArray[i] = dsDefs.get(i));
rrdDef.addDatasource(dsDefArray);
rrdDef.setStep(RESOLUTION_IN_SECOND);
// raw archive, no aggregation is required
ArcDef rawArchive = new ArcDef(CONSOL_FUNCTION, XFF_VALUE,
STEP_VALUE, ROW_VALUE);
rrdDef.addArchive(rawArchive);
// always store the metric data in memory...
rrdDb = new RrdDb(rrdDef, RrdBackendFactory.getFactory(STORING_METHOD));
} catch (IOException e) {
log.warn("Failed to create a new round-robin database due to {}", e);
}
return new DefaultMetricsDatabase(metricName, resourceName, rrdDb);
}
示例4: genMDbBuilder
import org.onosproject.cpman.MetricsDatabase; //导入依赖的package包/类
private MetricsDatabase.Builder genMDbBuilder(ControlResource.Type resourceType,
Set<ControlMetricType> metricTypes) {
MetricsDatabase.Builder builder = new DefaultMetricsDatabase.Builder();
builder.withMetricName(resourceType.toString());
metricTypes.forEach(type -> builder.addMetricType(type.toString()));
return builder;
}
示例5: withResourceName
import org.onosproject.cpman.MetricsDatabase; //导入依赖的package包/类
@Override
public MetricsDatabase.Builder withResourceName(String resource) {
this.resourceName = resource;
return this;
}
示例6: DefaultControlLoad
import org.onosproject.cpman.MetricsDatabase; //导入依赖的package包/类
/**
* Constructs a control load using the given metrics database and
* control metric type.
*
* @param mdb metrics database
* @param type control metric type
*/
public DefaultControlLoad(MetricsDatabase mdb, ControlMetricType type) {
this.mdb = mdb;
this.type = type;
}