use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class OF13MatchSerializerTest method testSerializeExperimenterMatchEntry.
/**
* Test serialize experimenter match entry - with no experimenter
* match entry serializer registered.
*/
@Test(expected = IllegalStateException.class)
public void testSerializeExperimenterMatchEntry() {
final List<MatchEntry> entries = new ArrayList<>();
MatchEntryBuilder builder = new MatchEntryBuilder();
builder.setOxmClass(ExperimenterClass.class);
builder.setOxmMatchField(OxmMatchFieldClass.class);
builder.setHasMask(true);
ExperimenterIdCaseBuilder caseBuilder = new ExperimenterIdCaseBuilder();
ExperimenterBuilder expBuilder = new ExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
caseBuilder.setExperimenter(expBuilder.build());
builder.setMatchEntryValue(caseBuilder.build());
entries.add(builder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
((OF13MatchSerializer) matchSerializer).serializeMatchEntries(entries, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class DeviceContextImpl method processExperimenterMessage.
@Override
public void processExperimenterMessage(final ExperimenterMessage notification) {
if (isMasterOfDevice()) {
// lookup converter
final ExperimenterDataOfChoice vendorData = notification.getExperimenterDataOfChoice();
final MessageTypeKey<? extends ExperimenterDataOfChoice> key = new MessageTypeKey<>(getDeviceInfo().getVersion(), (Class<? extends ExperimenterDataOfChoice>) vendorData.getImplementedInterface());
final ConvertorMessageFromOFJava<ExperimenterDataOfChoice, MessagePath> messageConverter = extensionConverterProvider.getMessageConverter(key);
if (messageConverter == null) {
LOG.warn("custom converter for {}[OF:{}] not found", notification.getExperimenterDataOfChoice().getImplementedInterface(), getDeviceInfo().getVersion());
return;
}
// build notification
final ExperimenterMessageOfChoice messageOfChoice;
try {
messageOfChoice = messageConverter.convert(vendorData, MessagePath.MESSAGE_NOTIFICATION);
final ExperimenterMessageFromDevBuilder experimenterMessageFromDevBld = new ExperimenterMessageFromDevBuilder().setNode(new NodeRef(getDeviceInfo().getNodeInstanceIdentifier())).setExperimenterMessageOfChoice(messageOfChoice);
// publish
notificationPublishService.offerNotification(experimenterMessageFromDevBld.build());
} catch (final ConversionException e) {
LOG.error("Conversion of experimenter notification failed", e);
}
} else {
LOG.debug("Controller is not owner of the device {}, skipping experimenter message", deviceInfo.getLOGValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class OF10StatsRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
expBuilder.setExperimenterDataOfChoice(vendorData);
caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 16);
Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class ActionDeserializer method deserialize.
@Override
public Action deserialize(ByteBuf message) {
final int startPosition = message.readerIndex();
// size of experimenter type
message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
// size of length
message.skipBytes(EncodeConstants.SIZE_OF_SHORT_IN_BYTES);
long experimenterId = message.readUnsignedInt();
if (NiciraConstants.NX_VENDOR_ID != experimenterId) {
throw new IllegalStateException("Experimenter ID is not Nicira vendor id but is " + experimenterId);
}
int subtype = message.readUnsignedShort();
NiciraActionDeserializerKey key = new NiciraActionDeserializerKey(version, subtype);
OFDeserializer<Action> actionDeserializer = NiciraExtensionCodecRegistratorImpl.getActionDeserializer(key);
if (actionDeserializer == null) {
LOG.info("No deserializer was found for key {}", key);
return null;
}
message.readerIndex(startPosition);
return actionDeserializer.deserialize(message);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.band.type.band.type.Experimenter in project openflowplugin by opendaylight.
the class OF10StatsReplyExperimenterTest method test.
/**
* Tests {@link OF10StatsReplyMessageFactory} for experimenter body translation.
*/
@Test
public void test() {
Mockito.when(registry.getDeserializer(Matchers.<MessageCodeKey>any())).thenReturn(vendorDeserializer);
OF10StatsReplyMessageFactory factory = new OF10StatsReplyMessageFactory();
factory.injectDeserializerRegistry(registry);
ByteBuf bb = BufferHelper.buildBuffer("FF FF 00 01 00 00 00 00 " + // expID
"00 00 00 01");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV10(builtByFactory);
Assert.assertEquals("Wrong type", 65535, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
Mockito.verify(vendorDeserializer).deserialize(bb);
}
Aggregations