本文整理匯總了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;
}