use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply in project openflowplugin by opendaylight.
the class MultiLayerTableMultipartService method convertToSalTableFeatures.
protected List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> convertToSalTableFeatures(final List<MultipartReply> multipartReplies) {
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures> salTableFeaturesAll = new ArrayList<>();
for (final MultipartReply multipartReply : multipartReplies) {
if (multipartReply.getType().equals(MultipartType.OFPMPTABLEFEATURES)) {
final MultipartReplyBody multipartReplyBody = multipartReply.getMultipartReplyBody();
if (multipartReplyBody instanceof MultipartReplyTableFeaturesCase) {
final MultipartReplyTableFeaturesCase tableFeaturesCase = (MultipartReplyTableFeaturesCase) multipartReplyBody;
final MultipartReplyTableFeatures salTableFeatures = tableFeaturesCase.getMultipartReplyTableFeatures();
final Optional<List<TableFeatures>> salTableFeaturesPartial = convertorExecutor.convert(salTableFeatures, data);
salTableFeaturesPartial.ifPresent(salTableFeaturesAll::addAll);
LOG.debug("TableFeature {} for xid {}.", salTableFeatures, multipartReply.getXid());
}
}
}
return salTableFeaturesAll;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply in project openflowplugin by opendaylight.
the class AbstractCompatibleStatService method handleAndNotify.
@Override
public ListenableFuture<RpcResult<O>> handleAndNotify(final I input, final NotificationPublishService notificationPublishService) {
// prepare emulated xid
final long emulatedXid = compatibilityXidSeed.incrementAndGet();
final TransactionId emulatedTxId = new TransactionId(BigInteger.valueOf(emulatedXid));
// do real processing
final ListenableFuture<RpcResult<List<MultipartReply>>> rpcResultListenableFuture = handleServiceCall(input);
// hook notification publishing
Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<List<MultipartReply>>>() {
@Override
public void onSuccess(@Nullable RpcResult<List<MultipartReply>> result) {
if (result != null && result.isSuccessful()) {
// transform rpc result (raw multipart) to notification
final N flowNotification = transformToNotification(result.getResult(), emulatedTxId);
notificationPublishService.offerNotification(flowNotification);
} else {
LOG.debug("compatibility callback failed - NOT emitting notification: {}", input.getClass().getSimpleName());
}
}
@Override
public void onFailure(Throwable throwable) {
LOG.debug("compatibility callback crashed - NOT emitting notification: {}", input.getClass().getSimpleName(), throwable);
}
}, MoreExecutors.directExecutor());
return RpcResultBuilder.<O>success(buildTxCapableResult(emulatedTxId)).buildFuture();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply in project openflowplugin by opendaylight.
the class FlowStatisticsToNotificationTransformer method transformToNotification.
/**
* Transform to notification.
*
* @param mpResult raw multipart response from device
* @param deviceInfo device state
* @param ofVersion device version
* @param emulatedTxId emulated transaction Id
* @param convertorExecutor convertor executor
* @return notification containing flow stats
*/
public static FlowsStatisticsUpdate transformToNotification(final List<MultipartReply> mpResult, final DeviceInfo deviceInfo, final OpenflowVersion ofVersion, final TransactionId emulatedTxId, final ConvertorExecutor convertorExecutor) {
final FlowStatsResponseConvertorData data = new FlowStatsResponseConvertorData(ofVersion.getVersion());
data.setDatapathId(deviceInfo.getDatapathId());
data.setMatchPath(MatchPath.FLOWS_STATISTICS_UPDATE_MATCH);
final FlowsStatisticsUpdateBuilder notification = new FlowsStatisticsUpdateBuilder();
final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
notification.setId(deviceInfo.getNodeId());
notification.setFlowAndStatisticsMapList(statsList);
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
for (MultipartReply mpRawReply : mpResult) {
Preconditions.checkArgument(MultipartType.OFPMPFLOW.equals(mpRawReply.getType()));
MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpRawReply.getMultipartReplyBody();
MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
final Optional<List<FlowAndStatisticsMapList>> outStatsItem = convertorExecutor.convert(replyBody.getFlowStats(), data);
outStatsItem.ifPresent(statsList::addAll);
}
return notification.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply in project openflowplugin by opendaylight.
the class FlowDirectStatisticsService method buildReply.
@Override
protected GetFlowStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
final List<FlowAndStatisticsMapList> statsList = new ArrayList<>();
if (success) {
for (final MultipartReply mpReply : input) {
final MultipartReplyFlowCase caseBody = (MultipartReplyFlowCase) mpReply.getMultipartReplyBody();
final MultipartReplyFlow replyBody = caseBody.getMultipartReplyFlow();
final Optional<List<FlowAndStatisticsMapList>> statsListPart = getConvertorExecutor().convert(replyBody.getFlowStats(), data);
statsListPart.ifPresent(flowAndStatisticsMapLists -> {
for (final FlowAndStatisticsMapList part : flowAndStatisticsMapLists) {
final FlowId flowId = new FlowId(generateFlowId(part).getValue());
statsList.add(new FlowAndStatisticsMapListBuilder(part).setKey(new FlowAndStatisticsMapListKey(flowId)).setFlowId(flowId).build());
}
});
}
}
return new GetFlowStatisticsOutputBuilder().setFlowAndStatisticsMapList(statsList).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply in project openflowplugin by opendaylight.
the class MeterFeaturesService method transformToNotification.
@Override
public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
final int mpSize = result.size();
Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
notification.setId(getDeviceInfo().getNodeId());
notification.setMoreReplies(Boolean.FALSE);
notification.setTransactionId(emulatedTxId);
MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
notification.setMaxBands(replyBody.getMaxBands());
notification.setMaxColor(replyBody.getMaxColor());
notification.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
notification.setMeterCapabilitiesSupported(extractMeterCapabilities(replyBody.getCapabilities()));
notification.setMeterBandSupported(extractSupportedMeterBand(replyBody, replyBody.getBandTypes()));
return notification.build();
}
Aggregations