本文整理了Java中org.onosproject.net.Annotations
类的一些代码示例,展示了Annotations
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotations
类的具体详情如下:
包路径:org.onosproject.net.Annotations
类名称:Annotations
暂无
代码示例来源:origin: org.onosproject/onos-apps-optical-model
@Override
public String value(String key) {
if (filtered.contains(key)) {
return null;
}
return delegate.value(key);
}
代码示例来源:origin: org.onosproject/onos-cli
/**
* Produces a JSON object from the specified key/value annotations.
*
* @param mapper ObjectMapper to use while converting to JSON
* @param annotations key/value annotations
* @return JSON object
*/
public static ObjectNode annotations(ObjectMapper mapper, Annotations annotations) {
ObjectNode result = mapper.createObjectNode();
for (String key : annotations.keys()) {
result.put(key, annotations.value(key));
}
return result;
}
代码示例来源:origin: org.onosproject/onos-apps-optical-model
@Override
public Set<String> keys() {
return Sets.difference(delegate.keys(), filtered);
}
代码示例来源:origin: org.onosproject/onos-core-common
/**
* Adds JSON encoding of the given item annotations to the specified node.
*
* @param node node to add annotations to
* @param entity annotated entity
* @param context encode context
* @return the given node
*/
protected ObjectNode annotate(ObjectNode node, T entity, CodecContext context) {
if (!entity.annotations().keys().isEmpty()) {
JsonCodec<Annotations> codec = context.codec(Annotations.class);
node.set("annotations", codec.encode(entity.annotations(), context));
}
return node;
}
代码示例来源:origin: org.onosproject/onos-app-vtn-mgr
/**
* Get the ControllerIp from the device .
*
* @param device Device
* @return Controller Ip
*/
public static String getControllerIpOfSwitch(Device device) {
String url = device.annotations().value(SWITCH_CHANNEL_ID);
return url.substring(0, url.lastIndexOf(":"));
}
代码示例来源:origin: org.onosproject/onos-core-common
@Override
public ObjectNode encode(Annotations annotations, CodecContext context) {
ObjectNode result = context.mapper().createObjectNode();
Set<String> keys = new TreeSet<>(annotations.keys());
for (String key : keys) {
result.put(key, annotations.value(key));
}
return result;
}
代码示例来源:origin: org.onosproject/onos-apps-optical-model
@Override
public String toString() {
Map<String, String> mapView = new HashMap<>();
keys().forEach(key -> mapView.put(key, delegate.value(key)));
return mapView.toString();
}
}
代码示例来源:origin: org.onosproject/onos-lldp-provider
private boolean containsSuppressionAnnotation(final Annotations annotations) {
for (Entry<String, String> entry : suppressedAnnotation.entrySet()) {
final String suppValue = entry.getValue();
final String suppKey = entry.getKey();
if (suppValue == ANY_VALUE) {
if (annotations.keys().contains(suppKey)) {
return true;
}
} else {
if (suppValue.equals(annotations.value(suppKey))) {
return true;
}
}
}
return false;
}
代码示例来源:origin: org.onosproject/onos-app-sfc-mgr
/**
* Get the ControllerIp from the device .
*
* @param device Device
* @return Controller Ip
*/
public String getControllerIpOfSwitch(Device device) {
String url = device.annotations().value(SWITCH_CHANNEL_ID);
return url.substring(0, url.lastIndexOf(":"));
}
代码示例来源:origin: org.onosproject/onos-cli
/**
* Produces a string image of the specified key/value annotations.
*
* @param annotations key/value annotations
* @return string image with ", k1=v1, k2=v2, ..." pairs
*/
public static String annotations(Annotations annotations) {
if (annotations == null) {
annotations = DefaultAnnotations.EMPTY;
}
StringBuilder sb = new StringBuilder();
Set<String> keys = new TreeSet<>(annotations.keys());
for (String key : keys) {
sb.append(", ").append(key).append('=').append(annotations.value(key));
}
return sb.toString();
}
代码示例来源:origin: org.onosproject/onos-core-net
private boolean canMarkOnline(Device device) {
final boolean providerMarkOnline = Boolean.parseBoolean(
device.annotations().value(AnnotationKeys.PROVIDER_MARK_ONLINE));
return !providerMarkOnline;
}
代码示例来源:origin: org.onosproject/onos-cli
/**
* Produces a string image of the specified key/value annotations.
* Excludes the keys in the given Set.
*
* @param annotations key/value annotations
* @param excludedKeys keys not to add in the resulting string
* @return string image with ", k1=v1, k2=v2, ..." pairs
*/
public static String annotations(Annotations annotations, Set<String> excludedKeys) {
StringBuilder sb = new StringBuilder();
Set<String> keys = new TreeSet<>(annotations.keys());
keys.removeAll(excludedKeys);
for (String key : keys) {
sb.append(", ").append(key).append('=').append(annotations.value(key));
}
return sb.toString();
}
代码示例来源:origin: org.onosproject/onos-apps-openstacknetworking-api
protected String getVni(Host host) {
return host.annotations().value(VXLAN_ID);
}
代码示例来源:origin: org.onosproject/onos-core-net
private DomainId getAnnotatedDomainId(Device device) {
if (!device.annotations().keys().contains(DOMAIN_ID)) {
return DomainId.LOCAL;
} else {
return DomainId.domainId(
device.annotations().value(DOMAIN_ID));
}
}
}
代码示例来源:origin: org.onosproject/onos-apps-openstacknetworking-api
protected String getTenantId(Host host) {
return host.annotations().value(TENANT_ID);
}
代码示例来源:origin: org.onosproject/onos-app-openstackswitching
/**
* Returns OpenstackPort object for the Port reference given.
*
* @param port Port object
* @return OpenstackPort reference, or null when not found
*/
public OpenstackPort openstackPort(Port port) {
String uuid = port.annotations().value(PORT_NAME).substring(3);
return openstackPortList.stream().filter(p -> p.id().startsWith(uuid))
.findAny().orElse(null);
}
代码示例来源:origin: org.onosproject/onos-apps-openstacknetworking-api
protected boolean isValidHost(Host host) {
return !host.ipAddresses().isEmpty() &&
host.annotations().value(VXLAN_ID) != null &&
host.annotations().value(NETWORK_ID) != null &&
host.annotations().value(TENANT_ID) != null &&
host.annotations().value(PORT_ID) != null;
}
代码示例来源:origin: org.onosproject/onos-app-openstackswitching
private PortNumber getTunnelPort(DeviceId deviceId) {
Port port = deviceService.getPorts(deviceId).stream()
.filter(p -> p.annotations().value(PORT_NAME).equals(
OpenstackSwitchingManager.PORTNAME_PREFIX_TUNNEL))
.findAny().orElse(null);
if (port == null) {
log.error("No TunnelPort was created.");
return null;
}
return port.number();
}
代码示例来源:origin: org.onosproject/onos-app-openstackinterface-app
@Override
public OpenstackPort port(Port port) {
String uuid = port.annotations().value(PORT_NAME).substring(3);
return getPorts().stream()
.filter(p -> p.id().startsWith(uuid))
.findAny().orElse(null);
}
代码示例来源:origin: org.onosproject/onos-apps-optical-model
public static Optional<OmsPort> asOmsPort(Port port) {
if (port instanceof OmsPort) {
return Optional.of((OmsPort) port);
}
try {
Annotations an = port.annotations();
Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MIN_FREQ_HZ)));
Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.MAX_FREQ_HZ)));
Frequency grid = Frequency.ofHz(Long.parseLong(an.value(OpticalAnnotations.GRID_HZ)));
return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid));
} catch (NumberFormatException e) {
log.warn("{} was not well-formed OMS port.", port, e);
return Optional.empty();
}
}
内容来源于网络,如有侵权,请联系作者删除!