From 10685eabc83aaec4bb08a8c401a4d84518848089 Mon Sep 17 00:00:00 2001 From: Michal Rehak Date: Tue, 16 Sep 2014 19:15:12 +0200 Subject: [PATCH] BUG-1952 Flow update rpc - in case that delete and recreate of flow is required then the action after delete should be add -> was modify - fixed xid propagation to notification - using RpcResultBuilder Change-Id: Idd519256519e32b2cd475b4cd954fe16f7518e66 Signed-off-by: Michal Rehak --- .../md/core/sal/NotificationComposer.java | 5 +- .../md/core/sal/OFRpcTaskFactory.java | 168 ++++++++---------- .../openflow/md/core/sal/OFRpcTaskUtil.java | 27 +-- 3 files changed, 95 insertions(+), 105 deletions(-) diff --git a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/sal/NotificationComposer.java b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/sal/NotificationComposer.java index a0421eb9bc..ac218b508c 100644 --- a/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/sal/NotificationComposer.java +++ b/openflowplugin-api/src/main/java/org/opendaylight/openflowplugin/api/openflow/md/core/sal/NotificationComposer.java @@ -7,16 +7,17 @@ */ package org.opendaylight.openflowplugin.api.openflow.md.core.sal; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId; import org.opendaylight.yangtools.yang.binding.Notification; /** * @param type of notification - * */ public interface NotificationComposer { /** + * @param xid corresponding OF transaction id * @return notification instance */ - N compose(); + N compose(TransactionId xid); } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskFactory.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskFactory.java index 7eae781428..0bc2b67bbe 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskFactory.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskFactory.java @@ -13,8 +13,7 @@ import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.JdkFutureAdapters; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; -import org.opendaylight.controller.sal.common.util.RpcErrors; -import org.opendaylight.controller.sal.common.util.Rpcs; + import org.opendaylight.openflowjava.protocol.api.util.BinContent; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher; @@ -29,6 +28,7 @@ import org.opendaylight.openflowplugin.openflow.md.util.FlowCreatorUtil; import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil; import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved; @@ -159,9 +159,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.Upd import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutputBuilder; import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -176,7 +176,7 @@ import java.util.concurrent.Future; * */ public abstract class OFRpcTaskFactory { - private static final Logger logger = LoggerFactory.getLogger(OFRpcTaskFactory.class); + protected static final Logger logger = LoggerFactory.getLogger(OFRpcTaskFactory.class); /** * @param taskContext @@ -204,13 +204,11 @@ public abstract class OFRpcTaskFactory { logger.debug("Number of flows to push to switch: {}", ofFlowModInputs.size()); - Long xId = getSession().getNextXid(); - result = chainFlowMods(ofFlowModInputs, 0, getTaskContext(), getCookie()); OFRpcTaskUtil.hookFutureNotification(this, result, getRpcNotificationProviderService(), - createFlowAddedNotification(xId, getInput())); + createFlowAddedNotification(getInput())); } return result; } @@ -226,7 +224,7 @@ public abstract class OFRpcTaskFactory { * All the flowmods should have the same xid, in-order to cross-reference * the notification */ - private static ListenableFuture> chainFlowMods( + protected static ListenableFuture> chainFlowMods( final List ofFlowModInputs, final int index, final OFRpcTaskContext taskContext, final SwitchConnectionDistinguisher cookie) { @@ -245,7 +243,7 @@ public abstract class OFRpcTaskFactory { return chainFlowMods(ofFlowModInputs, index + 1, taskContext, cookie); } else { logger.warn("Flowmod failed. Any chained flowmods are ignored. xid:{}", - taskContext.getSession().getFeatures().getXid()); + ofFlowModInputs.get(index).getXid()); return Futures.immediateFuture(input); } } @@ -259,22 +257,22 @@ public abstract class OFRpcTaskFactory { private static Future> createResultForFlowMod( OFRpcTaskContext taskContext, FlowModInputBuilder flowModInput, SwitchConnectionDistinguisher cookie) { - flowModInput.setXid(taskContext.getSession().getFeatures().getXid()); + flowModInput.setXid(taskContext.getSession().getNextXid()); return taskContext.getMessageService().flowMod(flowModInput.build(), cookie); } /** - * @param xId + * @param input * @return */ protected static NotificationComposer createFlowAddedNotification( - final Long xId, final AddFlowInput input) { + final AddFlowInput input) { return new NotificationComposer() { @Override - public FlowAdded compose() { + public FlowAdded compose(TransactionId tXid) { FlowAddedBuilder newFlow = new FlowAddedBuilder((Flow) input); - newFlow.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + newFlow.setTransactionId(tXid); newFlow.setFlowRef(input.getFlowRef()); return newFlow.build(); } @@ -303,33 +301,36 @@ public abstract class OFRpcTaskFactory { OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture>) result), barrierErrors); } else { - Long xId = getSession().getNextXid(); boolean updatedFlow = (getInput().getUpdatedFlow().getMatch().equals(getInput().getOriginalFlow().getMatch())) && (getInput().getUpdatedFlow().getPriority().equals(getInput().getOriginalFlow().getPriority())); List allFlowMods = new ArrayList<>(); - List ofFlowModInputs = - FlowConvertor.toFlowModInputs(getInput().getUpdatedFlow(), - getVersion(), getSession().getFeatures().getDatapathId()); + List ofFlowModInputs; if (updatedFlow == false) { // if neither match nor priority matches, then we would need to remove the flow and add it //remove flow RemoveFlowInputBuilder removeflow = new RemoveFlowInputBuilder(getInput().getOriginalFlow()); - FlowModInputBuilder ofFlowRemoveInput = FlowConvertor.toFlowModInput(removeflow.build(), + List ofFlowRemoveInput = FlowConvertor.toFlowModInputs(removeflow.build(), getVersion(),getSession().getFeatures().getDatapathId()); - ofFlowRemoveInput.setXid(xId); // remove flow should be the first - allFlowMods.add(ofFlowRemoveInput); + allFlowMods.addAll(ofFlowRemoveInput); + AddFlowInputBuilder addFlowInputBuilder = new AddFlowInputBuilder(getInput().getUpdatedFlow()); + ofFlowModInputs = FlowConvertor.toFlowModInputs(addFlowInputBuilder.build(), + getVersion(), getSession().getFeatures().getDatapathId()); + } else { + ofFlowModInputs = FlowConvertor.toFlowModInputs(getInput().getUpdatedFlow(), + getVersion(), getSession().getFeatures().getDatapathId()); } allFlowMods.addAll(ofFlowModInputs); logger.debug("Number of flows to push to switch: {}", allFlowMods.size()); result = chainFlowMods(allFlowMods, 0, getTaskContext(), getCookie()); + OFRpcTaskUtil.hookFutureNotification(this, result, getRpcNotificationProviderService(), - createFlowUpdatedNotification(xId, getInput())); + createFlowUpdatedNotification(getInput())); } return result; } @@ -343,13 +344,12 @@ public abstract class OFRpcTaskFactory { * @param input * @return */ - protected static NotificationComposer createFlowUpdatedNotification( - final Long xId, final UpdateFlowInput input) { + protected static NotificationComposer createFlowUpdatedNotification(final UpdateFlowInput input) { return new NotificationComposer() { @Override - public FlowUpdated compose() { + public FlowUpdated compose(TransactionId tXid) { FlowUpdatedBuilder updFlow = new FlowUpdatedBuilder(input.getUpdatedFlow()); - updFlow.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + updFlow.setTransactionId(tXid); updFlow.setFlowRef(input.getFlowRef()); return updFlow.build(); } @@ -387,7 +387,7 @@ public abstract class OFRpcTaskFactory { result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib); OFRpcTaskUtil.hookFutureNotification(this, result, - getRpcNotificationProviderService(), createGroupAddedNotification(xId, getInput())); + getRpcNotificationProviderService(), createGroupAddedNotification(getInput())); } return result; @@ -399,17 +399,16 @@ public abstract class OFRpcTaskFactory { /** - * @param xId * @param input * @return */ protected static NotificationComposer createGroupAddedNotification( - final Long xId, final AddGroupInput input) { + final AddGroupInput input) { return new NotificationComposer() { @Override - public GroupAdded compose() { + public GroupAdded compose(TransactionId tXid) { GroupAddedBuilder groupMod = new GroupAddedBuilder((Group) input); - groupMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + groupMod.setTransactionId(tXid); groupMod.setGroupRef(input.getGroupRef()); return groupMod.build(); } @@ -446,7 +445,7 @@ public abstract class OFRpcTaskFactory { result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib); OFRpcTaskUtil.hookFutureNotification(this, result, - getRpcNotificationProviderService(), createMeterAddedNotification(xId, getInput())); + getRpcNotificationProviderService(), createMeterAddedNotification(getInput())); } return result; @@ -458,17 +457,16 @@ public abstract class OFRpcTaskFactory { } /** - * @param xId * @param input * @return */ protected static NotificationComposer createMeterAddedNotification( - final Long xId, final AddMeterInput input) { + final AddMeterInput input) { return new NotificationComposer() { @Override - public MeterAdded compose() { + public MeterAdded compose(TransactionId tXid) { MeterAddedBuilder meterMod = new MeterAddedBuilder((Meter) input); - meterMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + meterMod.setTransactionId(tXid); meterMod.setMeterRef(input.getMeterRef()); return meterMod.build(); } @@ -507,7 +505,7 @@ public abstract class OFRpcTaskFactory { result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib); OFRpcTaskUtil.hookFutureNotification(this, result, - getRpcNotificationProviderService(), createGroupUpdatedNotification(xId, getInput())); + getRpcNotificationProviderService(), createGroupUpdatedNotification(getInput())); } return result; } @@ -516,17 +514,16 @@ public abstract class OFRpcTaskFactory { } /** - * @param xId * @param input * @return */ protected static NotificationComposer createGroupUpdatedNotification( - final Long xId, final UpdateGroupInput input) { + final UpdateGroupInput input) { return new NotificationComposer() { @Override - public GroupUpdated compose() { + public GroupUpdated compose(TransactionId tXid) { GroupUpdatedBuilder groupMod = new GroupUpdatedBuilder(input.getUpdatedGroup()); - groupMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + groupMod.setTransactionId(tXid); groupMod.setGroupRef(input.getGroupRef()); return groupMod.build(); } @@ -564,7 +561,7 @@ public abstract class OFRpcTaskFactory { result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib); OFRpcTaskUtil.hookFutureNotification(this, result, - getRpcNotificationProviderService(), createMeterUpdatedNotification(xId, getInput())); + getRpcNotificationProviderService(), createMeterUpdatedNotification(getInput())); } return result; } @@ -573,17 +570,16 @@ public abstract class OFRpcTaskFactory { } /** - * @param xId * @param input * @return */ protected static NotificationComposer createMeterUpdatedNotification( - final Long xId, final UpdateMeterInput input) { + final UpdateMeterInput input) { return new NotificationComposer() { @Override - public MeterUpdated compose() { + public MeterUpdated compose(TransactionId tXid) { MeterUpdatedBuilder meterMod = new MeterUpdatedBuilder(input.getUpdatedMeter()); - meterMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + meterMod.setTransactionId(tXid); meterMod.setMeterRef(input.getMeterRef()); return meterMod.build(); } @@ -622,7 +618,7 @@ public abstract class OFRpcTaskFactory { result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib); OFRpcTaskUtil.hookFutureNotification(this, result, - getRpcNotificationProviderService(), createFlowRemovedNotification(xId, getInput())); + getRpcNotificationProviderService(), createFlowRemovedNotification(getInput())); } return result; @@ -633,16 +629,16 @@ public abstract class OFRpcTaskFactory { } /** - * @param xId + * @param input * @return */ protected static NotificationComposer createFlowRemovedNotification( - final Long xId, final RemoveFlowInput input) { + final RemoveFlowInput input) { return new NotificationComposer() { @Override - public FlowRemoved compose() { + public FlowRemoved compose(TransactionId tXid) { FlowRemovedBuilder removedFlow = new FlowRemovedBuilder((Flow) input); - removedFlow.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + removedFlow.setTransactionId(tXid); removedFlow.setFlowRef(input.getFlowRef()); return removedFlow.build(); } @@ -681,7 +677,7 @@ public abstract class OFRpcTaskFactory { result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib); OFRpcTaskUtil.hookFutureNotification(this, result, - getRpcNotificationProviderService(), createGroupRemovedNotification(xId, getInput())); + getRpcNotificationProviderService(), createGroupRemovedNotification(getInput())); } return result; @@ -692,17 +688,16 @@ public abstract class OFRpcTaskFactory { } /** - * @param xId * @param input * @return */ protected static NotificationComposer createGroupRemovedNotification( - final Long xId, final RemoveGroupInput input) { + final RemoveGroupInput input) { return new NotificationComposer() { @Override - public GroupRemoved compose() { + public GroupRemoved compose(TransactionId tXid) { GroupRemovedBuilder removedGroup = new GroupRemovedBuilder((Group) input); - removedGroup.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + removedGroup.setTransactionId(tXid); removedGroup.setGroupRef(input.getGroupRef()); return removedGroup.build(); } @@ -739,7 +734,7 @@ public abstract class OFRpcTaskFactory { result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib); OFRpcTaskUtil.hookFutureNotification(this, result, - getRpcNotificationProviderService(), createMeterRemovedNotification(xId, getInput())); + getRpcNotificationProviderService(), createMeterRemovedNotification(getInput())); } return result; @@ -751,17 +746,16 @@ public abstract class OFRpcTaskFactory { } /** - * @param xId * @param input * @return */ protected static NotificationComposer createMeterRemovedNotification( - final Long xId, final RemoveMeterInput input) { + final RemoveMeterInput input) { return new NotificationComposer() { @Override - public MeterRemoved compose() { + public MeterRemoved compose(TransactionId tXid) { MeterRemovedBuilder meterRemoved = new MeterRemovedBuilder((Meter) input); - meterRemoved.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue()))); + meterRemoved.setTransactionId(tXid); meterRemoved.setMeterRef(input.getMeterRef()); return meterRemoved.build(); } @@ -785,9 +779,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetAllGroupStatisticsOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetAllGroupStatisticsOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { @@ -850,9 +843,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetGroupDescriptionOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetGroupDescriptionOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { final Long xid = taskContext.getSession().getNextXid(); @@ -899,9 +891,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetGroupFeaturesOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetGroupFeaturesOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { final Long xid = taskContext.getSession().getNextXid(); @@ -948,9 +939,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetGroupStatisticsOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetGroupStatisticsOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { final Long xid = taskContext.getSession().getNextXid(); @@ -1001,9 +991,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetAllMeterConfigStatisticsOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetAllMeterConfigStatisticsOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { final Long xid = taskContext.getSession().getNextXid(); @@ -1058,9 +1047,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetAllMeterStatisticsOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetAllMeterStatisticsOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { final Long xid = taskContext.getSession().getNextXid(); @@ -1115,9 +1103,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetMeterFeaturesOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetMeterFeaturesOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { final Long xid = taskContext.getSession().getNextXid(); @@ -1166,9 +1153,8 @@ public abstract class OFRpcTaskFactory { final SettableFuture> result = SettableFuture.create(); if (taskContext.getSession().getPrimaryConductor().getVersion() == OFConstants.OFP_VERSION_1_0) { - Collection errors = Collections.emptyList(); - RpcResult rpcResult = Rpcs.getRpcResult(true, - new GetMeterStatisticsOutputBuilder().build(), errors); + RpcResult rpcResult = RpcResultBuilder.success( + new GetMeterStatisticsOutputBuilder().build()).build(); return Futures.immediateFuture(rpcResult); } else { final Long xid = taskContext.getSession().getNextXid(); @@ -1829,17 +1815,17 @@ public abstract class OFRpcTaskFactory { @Override public void onSuccess(RpcResult resultArg) { - Collection errors = Collections.emptyList(); - result.set(Rpcs.getRpcResult(true, createResult(), errors)); + result.set(RpcResultBuilder.success(createResult()).build()); } @Override public void onFailure(Throwable t) { - result.set(Rpcs.getRpcResult(false, - Collections.singletonList(RpcErrors.getRpcError(OFConstants.APPLICATION_TAG, + result.set(RpcResultBuilder.failed().withWarning( + ErrorType.RPC, OFConstants.ERROR_TAG_TIMEOUT, - "something wrong happened", ErrorSeverity.WARNING, "", - ErrorType.RPC, t)))); + "something wrong happened", + OFConstants.APPLICATION_TAG, + "", t).build()); } } diff --git a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskUtil.java b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskUtil.java index 36f4276cd4..c44d16db32 100644 --- a/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskUtil.java +++ b/openflowplugin/src/main/java/org/opendaylight/openflowplugin/openflow/md/core/sal/OFRpcTaskUtil.java @@ -12,23 +12,22 @@ import java.util.Collections; import java.util.concurrent.Future; import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.common.util.RpcErrors; -import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.openflowplugin.api.OFConstants; +import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher; import org.opendaylight.openflowplugin.api.openflow.md.core.sal.NotificationComposer; +import org.opendaylight.openflowplugin.api.statistics.MessageSpy; import org.opendaylight.openflowplugin.openflow.md.core.MessageFactory; -import org.opendaylight.openflowplugin.api.openflow.md.core.SwitchConnectionDistinguisher; import org.opendaylight.openflowplugin.openflow.md.core.session.IMessageDispatchService; import org.opendaylight.openflowplugin.openflow.md.core.session.SessionContext; -import org.opendaylight.openflowplugin.api.statistics.MessageSpy; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionAware; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierOutput; import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.binding.Notification; import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import com.google.common.base.Objects; import com.google.common.collect.Lists; @@ -60,10 +59,13 @@ public abstract class OFRpcTaskUtil { errors = barrierResult.getErrors(); } } catch (Exception e) { - RpcError rpcError = RpcErrors.getRpcError( - OFConstants.APPLICATION_TAG, OFConstants.ERROR_TAG_TIMEOUT, - "barrier sending failed", ErrorSeverity.WARNING, - "switch failed to respond on barrier request - message ordering is not preserved", ErrorType.RPC, e); + RpcError rpcError = RpcResultBuilder.newWarning( + ErrorType.RPC, + OFConstants.ERROR_TAG_TIMEOUT, + "barrier sending failed", + OFConstants.APPLICATION_TAG, + "switch failed to respond on barrier request - message ordering is not preserved", + e); errors = Lists.newArrayList(rpcError); } } @@ -94,7 +96,7 @@ public abstract class OFRpcTaskUtil { */ public static void wrapBarrierErrors(SettableFuture> result, Collection barrierErrors) { - result.set(Rpcs.getRpcResult(false, barrierErrors)); + result.set(RpcResultBuilder.failed().withRpcErrors(barrierErrors).build()); } /** @@ -103,7 +105,8 @@ public abstract class OFRpcTaskUtil { * @param notificationProviderService * @param notificationComposer lazy notification composer */ - public static void hookFutureNotification( + public static , N extends Notification, INPUT extends DataContainer> + void hookFutureNotification( final OFRpcTask task, ListenableFuture originalResult, final NotificationProviderService notificationProviderService, @@ -112,7 +115,7 @@ public abstract class OFRpcTaskUtil { @Override public void onSuccess(R result) { if (null != notificationProviderService) { - notificationProviderService.publish(notificationComposer.compose()); + notificationProviderService.publish(notificationComposer.compose(result.getResult().getTransactionId())); } task.getTaskContext().getMessageSpy().spyMessage( task.getInput(), MessageSpy.STATISTIC_GROUP.TO_SWITCH_SUBMITTED_SUCCESS); -- 2.36.6