use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorUtil method translateMeterFeatures.
private static org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeatures translateMeterFeatures(final MultipartReply msg) {
MultipartReplyMeterFeaturesBuilder message = new MultipartReplyMeterFeaturesBuilder();
MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) msg.getMultipartReplyBody();
MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
message.setMaxBands(replyBody.getMaxBands());
message.setMaxColor(replyBody.getMaxColor());
message.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
List<Class<? extends MeterCapability>> supportedCapabilities = new ArrayList<>();
if (replyBody.getCapabilities().isOFPMFBURST()) {
supportedCapabilities.add(MeterBurst.class);
}
if (replyBody.getCapabilities().isOFPMFKBPS()) {
supportedCapabilities.add(MeterKbps.class);
}
if (replyBody.getCapabilities().isOFPMFPKTPS()) {
supportedCapabilities.add(MeterPktps.class);
}
if (replyBody.getCapabilities().isOFPMFSTATS()) {
supportedCapabilities.add(MeterStats.class);
}
message.setMeterCapabilitiesSupported(supportedCapabilities);
List<Class<? extends MeterBand>> supportedMeterBand = new ArrayList<>();
if (replyBody.getBandTypes().isOFPMBTDROP()) {
supportedMeterBand.add(MeterBandDrop.class);
}
if (replyBody.getBandTypes().isOFPMBTDSCPREMARK()) {
supportedMeterBand.add(MeterBandDscpRemark.class);
}
message.setMeterBandSupported(supportedMeterBand);
return message.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message 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.params.xml.ns.yang.pcep.types.rev181109.Message 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.Message in project openflowplugin by opendaylight.
the class DeviceContextImpl method processPacketInMessage.
@Override
public void processPacketInMessage(final PacketInMessage packetInMessage) {
if (isMasterOfDevice()) {
final PacketReceived packetReceived = packetInTranslator.translate(packetInMessage, getDeviceInfo(), null);
handlePacketInMessage(packetReceived, packetInMessage.getImplementedInterface(), packetReceived.getMatch());
} else {
LOG.debug("Controller is not owner of the device {}, skipping packet_in message", deviceInfo.getLOGValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message 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());
}
}
Aggregations