use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class MessageDeserializerInjector method injectDeserializers.
/**
* Injects message deserializers into provided.
* {@link org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerExtensionProvider}
*
* @param provider OpenflowJava deserializer extension provider
*/
static void injectDeserializers(final DeserializerExtensionProvider provider) {
// Inject new message deserializers here using injector created by createInjector method
final Function<Integer, Function<Class<? extends OfHeader>, Consumer<OFDeserializer<? extends OfHeader>>>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID);
injector.apply(10).apply(org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInMessage.class).accept(new PacketInMessageDeserializer());
injector.apply(19).apply(MultipartReply.class).accept(new MultipartReplyMessageDeserializer());
injector.apply(27).apply(AsyncConfigMessage.class).accept(new AsyncConfigMessageDeserializer());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class MessageDeserializerInjector method injectLegacyDeserializers.
@VisibleForTesting
static void injectLegacyDeserializers(final DeserializerExtensionProvider provider) {
final Function<Integer, Function<Class<? extends OfHeader>, Consumer<OFDeserializer<? extends OfHeader>>>> injector = createInjector(provider, EncodeConstants.OF13_VERSION_ID);
injector.apply(14).apply(FlowMessage.class).accept(new FlowMessageDeserializer());
injector.apply(15).apply(GroupMessage.class).accept(new GroupMessageDeserializer());
injector.apply(29).apply(MeterMessage.class).accept(new MeterMessageDeserializer());
injector.apply(16).apply(PortMessage.class).accept(new PortMessageDeserializer());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translate.
public static Optional<? extends MultipartReplyBody> translate(final OfHeader message, final DeviceInfo deviceInfo, @Nullable final ConvertorExecutor convertorExecutor, @Nullable final TranslatorLibrary translatorLibrary) {
if (message instanceof MultipartReply) {
final Optional<ConvertorExecutor> convertor = Optional.ofNullable(convertorExecutor);
final Optional<TranslatorLibrary> translator = Optional.ofNullable(translatorLibrary);
final MultipartReply msg = MultipartReply.class.cast(message);
final OpenflowVersion ofVersion = OpenflowVersion.get(deviceInfo.getVersion());
final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(deviceInfo.getVersion());
data.setDatapathId(deviceInfo.getDatapathId());
switch(msg.getType()) {
case OFPMPFLOW:
return convertor.flatMap(c -> Optional.of(translateFlow(msg, data, c)));
case OFPMPAGGREGATE:
return Optional.of(translateAggregate(msg));
case OFPMPPORTSTATS:
return Optional.of(translatePortStats(msg, ofVersion, deviceInfo.getDatapathId()));
case OFPMPGROUP:
return convertor.flatMap(c -> Optional.of(translateGroup(msg, data, c)));
case OFPMPGROUPDESC:
return convertor.flatMap(c -> Optional.of(translateGroupDesc(msg, data, c)));
case OFPMPGROUPFEATURES:
return Optional.of(translateGroupFeatures(msg));
case OFPMPMETER:
return convertor.flatMap(c -> Optional.of(translateMeter(msg, data, c)));
case OFPMPMETERCONFIG:
return convertor.flatMap(c -> Optional.of(translateMeterConfig(msg, data, c)));
case OFPMPMETERFEATURES:
return Optional.of(translateMeterFeatures(msg));
case OFPMPTABLE:
return Optional.of(translateTable(msg));
case OFPMPQUEUE:
return Optional.of(translateQueue(msg, ofVersion, deviceInfo.getDatapathId()));
case OFPMPDESC:
return Optional.of(translateDesc(msg));
case OFPMPTABLEFEATURES:
return convertor.flatMap(c -> Optional.of(translateTableFeatures(msg, deviceInfo.getVersion(), c)));
case OFPMPPORTDESC:
return translator.flatMap(t -> Optional.of(translatePortDesc(msg, deviceInfo, t)));
default:
}
} else if (message instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply) {
return Optional.of(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReply.class.cast(message).getMultipartReplyBody());
}
LOG.debug("Failed to translate {} for node {}.", message.getImplementedInterface(), deviceInfo);
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class OF13DeviceInitializer method initializeNodeInformation.
@Override
protected Future<Void> initializeNodeInformation(@Nonnull final DeviceContext deviceContext, final boolean switchFeaturesMandatory, final boolean skipTableFeatures, @Nullable final MultipartWriterProvider multipartWriterProvider, @Nullable final ConvertorExecutor convertorExecutor) {
final ConnectionContext connectionContext = Preconditions.checkNotNull(deviceContext.getPrimaryConnectionContext());
final DeviceState deviceState = Preconditions.checkNotNull(deviceContext.getDeviceState());
final DeviceInfo deviceInfo = Preconditions.checkNotNull(deviceContext.getDeviceInfo());
final Capabilities capabilities = connectionContext.getFeatures().getCapabilities();
LOG.debug("Setting capabilities for device {}", deviceInfo);
DeviceStateUtil.setDeviceStateBasedOnV13Capabilities(deviceState, capabilities);
// First process description reply, write data to DS and write consequent data if successful
return Futures.transformAsync(requestMultipart(MultipartType.OFPMPDESC, deviceContext), (AsyncFunction<RpcResult<List<OfHeader>>, Void>) input -> {
translateAndWriteResult(MultipartType.OFPMPDESC, input.getResult(), deviceContext, multipartWriterProvider, convertorExecutor);
final List<ListenableFuture<RpcResult<List<OfHeader>>>> futures = new ArrayList<>();
futures.add(requestAndProcessMultipart(MultipartType.OFPMPMETERFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
futures.add(requestAndProcessMultipart(MultipartType.OFPMPGROUPFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
futures.add(requestAndProcessMultipart(MultipartType.OFPMPTABLEFEATURES, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
futures.add(requestAndProcessMultipart(MultipartType.OFPMPPORTDESC, deviceContext, skipTableFeatures, multipartWriterProvider, convertorExecutor));
return Futures.transform(switchFeaturesMandatory ? Futures.allAsList(futures) : Futures.successfulAsList(futures), new Function<List<RpcResult<List<OfHeader>>>, Void>() {
@Nullable
@Override
public Void apply(@Nullable final List<RpcResult<List<OfHeader>>> input) {
LOG.info("Static node {} successfully finished collecting", deviceContext.getDeviceInfo());
return null;
}
}, MoreExecutors.directExecutor());
}, MoreExecutors.directExecutor());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader in project openflowplugin by opendaylight.
the class SalAsyncConfigServiceImplTest method testGetAsyncTest.
@Test
public void testGetAsyncTest() throws Exception {
final GetAsyncOutput getAsyncOutput = new GetAsyncOutputBuilder().build();
final RpcResult<GetAsyncOutput> replyRpcResult = RpcResultBuilder.success(getAsyncOutput).build();
final ListenableFuture<RpcResult<GetAsyncOutput>> replyFuture = Futures.immediateFuture(replyRpcResult);
Mockito.when(mockedRequestContext.getFuture()).thenReturn(replyFuture);
final Future<RpcResult<GetAsyncOutput>> getAsyncResult = salAsyncConfigService.getAsync(new GetAsyncInputBuilder().build());
Assert.assertNotNull(getAsyncResult);
Assert.assertTrue(getAsyncResult.isDone());
Assert.assertTrue(getAsyncResult.get().isSuccessful());
verify(mockedRequestContextStack).createRequestContext();
verify(mockedOutboundQueue).commitEntry(Matchers.eq(ServiceMocking.DUMMY_XID_VALUE), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
}
Aggregations