本文整理汇总了Java中org.onosproject.cpman.ControlResource类的典型用法代码示例。如果您正苦于以下问题:Java ControlResource类的具体用法?Java ControlResource怎么用?Java ControlResource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ControlResource类属于org.onosproject.cpman包,在下文中一共展示了ControlResource类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addMetrics
import org.onosproject.cpman.ControlResource; //导入依赖的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();
}
}
}
示例2: testDeviceMetricsMap
import org.onosproject.cpman.ControlResource; //导入依赖的package包/类
/**
* Tests device metrics map update and query.
*/
@Test
public void testDeviceMetricsMap() {
ControlResource.Type type = ControlResource.Type.CONTROL_MESSAGE;
DeviceId devId1 = DeviceId.deviceId("of:0000000000000101");
DeviceId devId2 = DeviceId.deviceId("of:0000000000000102");
devMetricsMap = Maps.newHashMap();
Set<DeviceId> devices = ImmutableSet.of(devId1, devId2);
devices.forEach(dev -> {
if (!devMetricsMap.containsKey(dev)) {
devMetricsMap.put(dev, genMDbBuilder(type, ControlResource.CONTROL_MESSAGE_METRICS)
.withResourceName(dev.toString())
.build());
}
});
Map<String, Double> metrics1 = new HashMap<>();
ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType ->
metrics1.putIfAbsent(msgType.toString(), 10D));
Map<String, Double> metrics2 = new HashMap<>();
ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType ->
metrics2.putIfAbsent(msgType.toString(), 20D));
devMetricsMap.get(devId1).updateMetrics(metrics1);
devMetricsMap.get(devId2).updateMetrics(metrics2);
ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType ->
assertThat(10D, is(devMetricsMap.get(devId1).recentMetric(msgType.toString())))
);
ControlResource.CONTROL_MESSAGE_METRICS.forEach(msgType ->
assertThat(20D, is(devMetricsMap.get(devId2).recentMetric(msgType.toString())))
);
}
示例3: genMDbBuilder
import org.onosproject.cpman.ControlResource; //导入依赖的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;
}
示例4: complete
import org.onosproject.cpman.ControlResource; //导入依赖的package包/类
@Override
public int complete(String buffer, int cursor, List<String> candidates) {
// delegate string completer
StringsCompleter delegate = new StringsCompleter();
// Resource type is the second argument.
ArgumentCompleter.ArgumentList list = getArgumentList();
String nodeId = list.getArguments()[1];
String type = list.getArguments()[2];
if (resourceTypes.contains(type)) {
ControlPlaneMonitorService monitorService =
AbstractShellCommand.get(ControlPlaneMonitorService.class);
Set<String> set = Sets.newHashSet();
switch (type) {
case NETWORK:
set = monitorService.availableResourcesSync(NodeId.nodeId(nodeId),
ControlResource.Type.NETWORK);
break;
case DISK:
set = monitorService.availableResourcesSync(NodeId.nodeId(nodeId),
ControlResource.Type.DISK);
break;
case CONTROL_MESSAGE:
set = monitorService.availableResourcesSync(NodeId.nodeId(nodeId),
ControlResource.Type.CONTROL_MESSAGE);
break;
default:
log.warn(INVALID_MSG);
break;
}
SortedSet<String> strings = delegate.getStrings();
if (!set.isEmpty()) {
set.forEach(strings::add);
}
}
return delegate.complete(buffer, cursor, candidates);
}
示例5: availableResources
import org.onosproject.cpman.ControlResource; //导入依赖的package包/类
@Override
public CompletableFuture<Set<String>> availableResources(NodeId nodeId,
ControlResource.Type resourceType) {
return null;
}
示例6: createResourceRequest
import org.onosproject.cpman.ControlResource; //导入依赖的package包/类
/**
* Generates a control resource request with given resource type.
*
* @param type control resource type
* @return control resource request instance
*/
private ControlResourceRequest createResourceRequest(ControlResource.Type type) {
return new ControlResourceRequest(type);
}