use of org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor 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.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor 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());
}
Aggregations