use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class InternalPortStatusEventSerializer method read.
@Override
public InternalPortStatusEvent read(Kryo kryo, Input input, Class<InternalPortStatusEvent> type) {
ProviderId providerId = (ProviderId) kryo.readClassAndObject(input);
DeviceId deviceId = kryo.readObject(input, DeviceId.class, deviceIdSerializer());
@SuppressWarnings("unchecked") Timestamped<PortDescription> portDescription = (Timestamped<PortDescription>) kryo.readClassAndObject(input);
return new InternalPortStatusEvent(providerId, deviceId, portDescription);
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class LinkProtoTranslator method translate.
/**
* Translates gRPC LinkCore message to {@link Link}.
*
* @param link gRPC message
* @return {@link Link} null if link is a default instance
*/
public static Link translate(LinkProtoOuterClass.LinkProto link) {
if (link.equals(LinkProtoOuterClass.LinkProto.getDefaultInstance())) {
return null;
}
ProviderId providerId = ProviderIdProtoTranslator.translate(link.getProviderId());
Link.State state = LinkEnumsProtoTranslator.translate(link.getState()).get();
ConnectPoint src = ConnectPointProtoTranslator.translate(link.getSrc()).get();
ConnectPoint dst = ConnectPointProtoTranslator.translate(link.getDst()).get();
Link.Type type = LinkEnumsProtoTranslator.translate(link.getType()).get();
Annotations annots = asAnnotations(link.getAnnotations());
Boolean isExpected = link.getIsExpected();
return DefaultLink.builder().state(state).annotations(annots).providerId(providerId).src(src).dst(dst).type(type).isExpected(isExpected).build();
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class ECLinkStore method removeLink.
@Override
public LinkEvent removeLink(ConnectPoint src, ConnectPoint dst) {
final LinkKey linkKey = LinkKey.linkKey(src, dst);
ProviderId primaryProviderId = getBaseProviderId(linkKey);
// Stop if there is no base provider.
if (primaryProviderId == null) {
return null;
}
LinkDescription removedLinkDescription = linkDescriptions.remove(new Provided<>(linkKey, primaryProviderId));
if (removedLinkDescription != null) {
return purgeLinkCache(linkKey);
}
return null;
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class DefaultLinkSerializer method read.
@Override
public DefaultLink read(Kryo kryo, Input input, Class<DefaultLink> type) {
ProviderId providerId = (ProviderId) kryo.readClassAndObject(input);
ConnectPoint src = (ConnectPoint) kryo.readClassAndObject(input);
ConnectPoint dst = (ConnectPoint) kryo.readClassAndObject(input);
Type linkType = (Type) kryo.readClassAndObject(input);
State state = (State) kryo.readClassAndObject(input);
boolean isDurable = input.readBoolean();
return DefaultLink.builder().providerId(providerId).src(src).dst(dst).type(linkType).state(state).isExpected(isDurable).build();
}
use of org.onosproject.net.provider.ProviderId in project onos by opennetworkinglab.
the class HostMonitorTest method testMonitorHostExists.
private void testMonitorHostExists(IpAddress hostIp) throws Exception {
ProviderId id = new ProviderId("fake://", "id");
Host host = createMock(Host.class);
expect(host.providerId()).andReturn(id).anyTimes();
replay(host);
HostManager hostManager = createMock(HostManager.class);
expect(hostManager.getHostsByIp(hostIp)).andReturn(Collections.singleton(host)).anyTimes();
replay(hostManager);
HostProvider hostProvider = createMock(HostProvider.class);
expect(hostProvider.id()).andReturn(id).anyTimes();
hostProvider.triggerProbe(host);
expectLastCall().times(2);
replay(hostProvider);
hostMonitor = new HostMonitor(null, hostManager, null, edgePortService, null);
hostMonitor.registerHostProvider(hostProvider);
hostMonitor.addMonitoringFor(hostIp);
hostMonitor.run();
verify(hostProvider);
}
Aggregations