本文整理汇总了Java中org.onosproject.cpman.ControlMetricType类的典型用法代码示例。如果您正苦于以下问题:Java ControlMetricType类的具体用法?Java ControlMetricType怎么用?Java ControlMetricType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ControlMetricType类属于org.onosproject.cpman包,在下文中一共展示了ControlMetricType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLocalLoad
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Returns local control load.
*
* @param type metric type
* @param deviceId device identifier
* @return control load
*/
private ControlLoad getLocalLoad(ControlMetricType type,
Optional<DeviceId> deviceId) {
if (deviceId.isPresent()) {
// returns control message stats
if (CONTROL_MESSAGE_METRICS.contains(type) &&
availableDeviceIdSet.contains(deviceId.get())) {
return new DefaultControlLoad(controlMessageMap.get(deviceId.get()), type);
}
} else {
// returns controlLoad of CPU metrics
if (CPU_METRICS.contains(type)) {
return new DefaultControlLoad(cpuMetrics, type);
}
// returns memoryLoad of memory metrics
if (MEMORY_METRICS.contains(type)) {
return new DefaultControlLoad(memoryMetrics, type);
}
}
return null;
}
示例2: generateMatrix
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
private Map<ControlMetricType, Long[]> generateMatrix(ControlPlaneMonitorService cpms,
ClusterService cs, DeviceId deviceId) {
Map<ControlMetricType, Long[]> data = Maps.newHashMap();
for (ControlMetricType cmt : CONTROL_MESSAGE_METRICS) {
ControlLoadSnapshot cls = cpms.getLoadSync(cs.getLocalNode().id(),
cmt, NUM_OF_DATA_POINTS, TimeUnit.MINUTES, Optional.of(deviceId));
// TODO: in some cases, the number of returned data set is
// less than what we expected (expected -1)
// As a workaround, we simply fill the slot with 0 values,
// such a bug should be fixed with updated RRD4J lib...
data.put(cmt, ArrayUtils.toObject(fillData(cls.recent(), NUM_OF_DATA_POINTS)));
timestamp = cls.time();
}
return data;
}
示例3: testLookupControlMetricType
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Tests whether control message metric mapper returns right control metric type.
*/
@Test
public void testLookupControlMetricType() {
assertThat(lookupControlMetricType(ControlMessage.Type.INBOUND_PACKET),
is(ControlMetricType.INBOUND_PACKET));
assertThat(lookupControlMetricType(ControlMessage.Type.OUTBOUND_PACKET),
is(ControlMetricType.OUTBOUND_PACKET));
assertThat(lookupControlMetricType(ControlMessage.Type.FLOW_MOD_PACKET),
is(ControlMetricType.FLOW_MOD_PACKET));
assertThat(lookupControlMetricType(ControlMessage.Type.FLOW_REMOVED_PACKET),
is(ControlMetricType.FLOW_REMOVED_PACKET));
assertThat(lookupControlMetricType(ControlMessage.Type.REQUEST_PACKET),
is(ControlMetricType.REQUEST_PACKET));
assertThat(lookupControlMetricType(ControlMessage.Type.REPLY_PACKET),
is(ControlMetricType.REPLY_PACKET));
}
示例4: testLookupControlMessageType
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Tests whether control message metric mapper returns right control message type.
*/
@Test
public void testLookupControlMessageType() {
assertThat(lookupControlMessageType(ControlMetricType.INBOUND_PACKET),
is(ControlMessage.Type.INBOUND_PACKET));
assertThat(lookupControlMessageType(ControlMetricType.OUTBOUND_PACKET),
is(ControlMessage.Type.OUTBOUND_PACKET));
assertThat(lookupControlMessageType(ControlMetricType.FLOW_MOD_PACKET),
is(ControlMessage.Type.FLOW_MOD_PACKET));
assertThat(lookupControlMessageType(ControlMetricType.FLOW_REMOVED_PACKET),
is(ControlMessage.Type.FLOW_REMOVED_PACKET));
assertThat(lookupControlMessageType(ControlMetricType.REQUEST_PACKET),
is(ControlMessage.Type.REQUEST_PACKET));
assertThat(lookupControlMessageType(ControlMetricType.REPLY_PACKET),
is(ControlMessage.Type.REPLY_PACKET));
}
示例5: processRest
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Transforms control load snapshot object into JSON object.
*
* @param cls control load snapshot
* @param type control metric type
* @param metricsNode array of JSON node
*/
private void processRest(ControlLoadSnapshot cls, ControlMetricType type, ArrayNode metricsNode) {
ObjectNode metricNode = mapper().createObjectNode();
if (cls != null) {
metricNode.set(toCamelCase(type.toString(), true),
codec(ControlLoadSnapshot.class).encode(cls, this));
metricsNode.add(metricNode);
}
}
示例6: increment
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Increments disk or network metric value.
*
* @param resourceName resource name
* @param resourceType resource type
* @param type control metric type
* @param value metric value
*/
public void increment(String resourceName, String resourceType, ControlMetricType type, long value) {
if (DISK_RESOURCE_TYPE.equals(resourceType) && diskMap.containsKey(resourceName)) {
diskMap.get(resourceName).get(type).mark(value);
}
if (NETWORK_RESOURCE_TYPE.equals(resourceType) && networkMap.containsKey(resourceName)) {
networkMap.get(resourceName).get(type).mark(value);
}
}
示例7: addMetrics
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Adds a set of new monitoring metric types.
*
* @param optResourceName optional resource name, null denotes system metric
* @param resType resource type
*/
public void addMetrics(Optional<String> optResourceName, String resType) {
Set<ControlMetricType> metricTypeSet = Sets.newHashSet();
String resourceName = optResourceName.isPresent() ?
optResourceName.get() : DEFAULT_RESOURCE_NAME;
MetricsComponent metricsComponent = metricsService.registerComponent(resourceName);
if (optResourceName.isPresent()) {
if (!diskMap.containsKey(resourceName) && DISK_RESOURCE_TYPE.equals(resType)) {
metricTypeSet.addAll(ControlResource.DISK_METRICS);
diskMap.putIfAbsent(resourceName,
getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
} else if (!networkMap.containsKey(resourceName) && NETWORK_RESOURCE_TYPE.equals(resType)) {
metricTypeSet.addAll(ControlResource.NETWORK_METRICS);
networkMap.putIfAbsent(resourceName,
getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
} else {
return;
}
} else {
if (systemMap.isEmpty()) {
metricTypeSet.addAll(ControlResource.MEMORY_METRICS);
metricTypeSet.addAll(ControlResource.CPU_METRICS);
systemMap.putAll(getMeterMap(metricTypeSet, metricsComponent, metricsService));
metricsService.notifyReporters();
}
}
}
示例8: getMeterMap
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
private Map<ControlMetricType, Meter> getMeterMap(Set<ControlMetricType> types,
MetricsComponent component,
MetricsService service) {
Map<ControlMetricType, Meter> meterMap = Maps.newHashMap();
types.forEach(type -> {
MetricsFeature metricsFeature = component.registerFeature(type.toString());
Meter meter = service.createMeter(component, metricsFeature, DEFAULT_METER_SUFFIX);
meterMap.putIfAbsent(type, meter);
});
return meterMap;
}
示例9: getLoad
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
@Override
public CompletableFuture<ControlLoadSnapshot> getLoad(NodeId nodeId,
ControlMetricType type,
Optional<DeviceId> deviceId) {
if (clusterService.getLocalNode().id().equals(nodeId)) {
return CompletableFuture.completedFuture(snapshot(getLocalLoad(type, deviceId)));
} else {
return communicationService.sendAndReceive(createMetricsRequest(type, deviceId),
CONTROL_STATS, SERIALIZER::encode, SERIALIZER::decode, nodeId);
}
}
示例10: genMDbBuilder
import org.onosproject.cpman.ControlMetricType; //导入依赖的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();
}
示例11: updateNetworkMetrics
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Updates network metrics with given metric map and resource name.
*
* @param metricMap a metric map which is comprised of metric type and value
* @param resourceName resource name
*/
private void updateNetworkMetrics(Map<ControlMetricType, Double> metricMap,
String resourceName) {
if (!networkMetricsMap.containsKey(resourceName)) {
networkMetricsMap.put(resourceName, genMDbBuilder(resourceName,
Type.NETWORK, NETWORK_METRICS));
}
networkMetricsMap.get(resourceName).updateMetrics(convertMap(metricMap));
}
示例12: updateDiskMetrics
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Updates disk metrics with given metric map and resource name.
*
* @param metricMap a metric map which is comprised of metric type and value
* @param resourceName resource name
*/
private void updateDiskMetrics(Map<ControlMetricType, Double> metricMap,
String resourceName) {
if (!diskMetricsMap.containsKey(resourceName)) {
diskMetricsMap.put(resourceName, genMDbBuilder(resourceName,
Type.DISK, DISK_METRICS));
}
diskMetricsMap.get(resourceName).updateMetrics(convertMap(metricMap));
}
示例13: updateControlMessages
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Updates control message metrics with given metric map and device identifier.
*
* @param metricMap a metric map which is comprised of metric type and value
* @param deviceId device identifier
*/
private void updateControlMessages(Map<ControlMetricType, Double> metricMap,
DeviceId deviceId) {
if (!controlMessageMap.containsKey(deviceId)) {
controlMessageMap.put(deviceId, genMDbBuilder(deviceId.toString(),
Type.CONTROL_MESSAGE, CONTROL_MESSAGE_METRICS));
}
controlMessageMap.get(deviceId).updateMetrics(convertMap(metricMap));
}
示例14: convertMap
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Converts metric map into a new map which contains string formatted metric type as key.
*
* @param metricMap metric map in which ControlMetricType is key
* @return a new map in which string formatted metric type is key
*/
private Map<String, Double> convertMap(Map<ControlMetricType, Double> metricMap) {
if (metricMap == null) {
return ImmutableMap.of();
}
Map newMap = Maps.newConcurrentMap();
metricMap.forEach((k, v) -> newMap.putIfAbsent(k.toString(), v));
return newMap;
}
示例15: printControlLoadSnapshot
import org.onosproject.cpman.ControlMetricType; //导入依赖的package包/类
/**
* Prints control load snapshot.
*
* @param cmType control metric type
* @param cls control load snapshot
*/
private void printControlLoadSnapshot(ControlMetricType cmType, ControlLoadSnapshot cls) {
if (cls != null) {
print(FMT, cmType.toString(), cls.latest(), cls.average(), cls.time());
} else {
print("Failed to retrieve metric value for type {}", cmType.toString());
}
}