use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class UdpDstCodecTest method deserializeTest.
@Test
public void deserializeTest() {
createBuffer(buffer);
input = udpDstCodec.deserialize(buffer);
final UdpDstCaseValue result = (UdpDstCaseValue) input.getMatchEntryValue();
assertEquals(Nxm0Class.class, input.getOxmClass());
assertEquals(NxmOfUdpDst.class, input.getOxmMatchField());
assertEquals(true, input.isHasMask());
assertEquals(1, result.getUdpDstValues().getPort().getValue().shortValue());
assertEquals(0xffff, result.getUdpDstValues().getMask().shortValue() & 0xffff);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class HandshakeManagerImpl method sendHelloMessage.
/**
* send hello reply without versionBitmap.
*
* @param helloVersion initial hello version for openflow connection negotiation
* @param helloXid transaction id
*/
private ListenableFuture<Void> sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception {
HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
final SettableFuture<Void> resultFtr = SettableFuture.create();
LOG.debug("sending hello message: version{}, xid={}, version bitmap={}", helloVersion, helloXid, MessageFactory.digVersions(helloInput.getElements()));
Future<RpcResult<Void>> helloResult = connectionAdapter.hello(helloInput);
ListenableFuture<RpcResult<Void>> rpcResultListenableFuture = JdkFutureAdapters.listenInPoolThread(helloResult);
Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<Void>>() {
@Override
public void onSuccess(@Nonnull RpcResult<Void> result) {
if (result.isSuccessful()) {
LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress());
resultFtr.set(null);
} else {
for (RpcError error : result.getErrors()) {
LOG.debug("hello sending failed [{}]: i:{} s:{} m:{}, addr:{}", helloXid, error.getInfo(), error.getSeverity(), error.getMessage(), connectionAdapter.getRemoteAddress());
if (error.getCause() != null) {
LOG.trace("DETAIL of sending hello failure", error.getCause());
}
}
resultFtr.cancel(false);
handshakeListener.onHandshakeFailure();
}
}
@Override
public void onFailure(Throwable throwable) {
LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
LOG.trace("DETAIL of sending of hello failure:", throwable);
resultFtr.cancel(false);
handshakeListener.onHandshakeFailure();
}
}, MoreExecutors.directExecutor());
LOG.trace("sending hello message [{}] - result hooked ..", helloXid);
return resultFtr;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class DeviceContextImpl method handlePacketInMessage.
private void handlePacketInMessage(final PacketIn packetIn, final Class<?> implementedInterface, final Match match) {
messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH);
final ConnectionAdapter connectionAdapter = getPrimaryConnectionContext().getConnectionAdapter();
if (packetIn == null) {
LOG.debug("Received a null packet from switch {}", connectionAdapter.getRemoteAddress());
messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_TRANSLATE_SRC_FAILURE);
return;
}
final OpenflowVersion openflowVersion = OpenflowVersion.get(deviceInfo.getVersion());
// Try to get ingress from match
final NodeConnectorRef nodeConnectorRef = Objects.nonNull(packetIn.getIngress()) ? packetIn.getIngress() : Optional.ofNullable(match).map(Match::getInPort).map(nodeConnectorId -> InventoryDataServiceUtil.portNumberfromNodeConnectorId(openflowVersion, nodeConnectorId)).map(portNumber -> InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(deviceInfo.getDatapathId(), portNumber, openflowVersion)).orElse(null);
messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_TRANSLATE_OUT_SUCCESS);
if (!packetInLimiter.acquirePermit()) {
LOG.debug("Packet limited");
// TODO: save packet into emergency slot if possible
messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_PACKET_IN_LIMIT_REACHED_AND_DROPPED);
return;
}
final ListenableFuture<?> offerNotification = notificationPublishService.offerNotification(new PacketReceivedBuilder(packetIn).setIngress(nodeConnectorRef).setMatch(MatchUtil.transformMatch(match, org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.packet.received.Match.class)).build());
if (NotificationPublishService.REJECTED.equals(offerNotification)) {
LOG.debug("notification offer rejected");
messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_NOTIFICATION_REJECTED);
packetInLimiter.drainLowWaterMark();
packetInLimiter.releasePermit();
return;
}
Futures.addCallback(offerNotification, new FutureCallback<Object>() {
@Override
public void onSuccess(final Object result) {
messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_PUBLISHED_SUCCESS);
packetInLimiter.releasePermit();
}
@Override
public void onFailure(final Throwable throwable) {
messageSpy.spyMessage(implementedInterface, MessageSpy.StatisticsGroup.FROM_SWITCH_NOTIFICATION_REJECTED);
LOG.debug("notification offer failed: {}", throwable.getMessage());
LOG.trace("notification offer failed..", throwable);
packetInLimiter.releasePermit();
}
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class ConvertorManagerTest method testConvert.
@Test
public void testConvert() throws Exception {
final ConvertorManager convertorManager = new ConvertorManager(OFConstants.OFP_VERSION_1_3).registerConvertor(OFConstants.OFP_VERSION_1_3, new Convertor<Action, String, VersionConvertorData>() {
@Override
public Collection<Class<?>> getTypes() {
return Collections.singleton(Action.class);
}
@Override
public String convert(Action source, VersionConvertorData data) {
return String.valueOf(source) + String.valueOf(data);
}
});
final Action source = new ActionBuilder().build();
final VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
final String expectedResult = String.valueOf(source) + String.valueOf(data);
final Optional<String> result = convertorManager.convert(source, data);
assertTrue("Failed to convert action to string", result.isPresent());
assertEquals("Result and expected result do not match", result.get(), expectedResult);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SingleLayerGroupServiceTest method buildRequest.
@Test
public void buildRequest() throws Exception {
final AddGroupInput input = new AddGroupInputBuilder().setGroupId(new GroupId(GROUP_ID)).build();
final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
assertEquals(GroupMessage.class, ofHeader.getImplementedInterface());
final GroupMessage result = GroupMessage.class.cast(ofHeader);
assertEquals(GroupModCommand.OFPGCADD, result.getCommand());
assertEquals(GROUP_ID, result.getGroupId().getValue().longValue());
}
Aggregations