當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。