当前位置: 首页>>代码示例>>Java>>正文


Java MetricsDatabase类代码示例

本文整理汇总了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)));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:21,代码来源:MetricsDatabaseTest.java

示例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();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:19,代码来源:ControlPlaneMonitor.java

示例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);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:31,代码来源:DefaultMetricsDatabase.java

示例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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:8,代码来源:MetricsDatabaseTest.java

示例5: withResourceName

import org.onosproject.cpman.MetricsDatabase; //导入依赖的package包/类
@Override
public MetricsDatabase.Builder withResourceName(String resource) {
    this.resourceName = resource;
    return this;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:DefaultMetricsDatabase.java

示例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;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:DefaultControlLoad.java


注:本文中的org.onosproject.cpman.MetricsDatabase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。