- if (null != getRpcNotificationProviderService()) {
- FlowAddedBuilder newFlow = new FlowAddedBuilder(
- (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.Flow) getInput());
- newFlow.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
- newFlow.setFlowRef(getInput().getFlowRef());
- getRpcNotificationProviderService().publish(newFlow.build());
+ /**
+ * @param xId
+ * @param input
+ * @return
+ */
+ protected static NotificationComposer<MeterAdded> createMeterAddedNotification(
+ final Long xId, final AddMeterInput input) {
+ return new NotificationComposer<MeterAdded>() {
+ @Override
+ public MeterAdded compose() {
+ MeterAddedBuilder meterMod = new MeterAddedBuilder((Meter) input);
+ meterMod.setTransactionId(new TransactionId(BigInteger.valueOf(xId.intValue())));
+ meterMod.setMeterRef(input.getMeterRef());
+ return meterMod.build();
+ }
+ };
+ }
+
+ /**
+ * @param taskContext
+ * @param input
+ * @param cookie
+ * @return UpdateFlow task
+ */
+ public static OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> createUpdateGroupTask(
+ OFRpcTaskContext taskContext, UpdateGroupInput input,
+ SwitchConnectionDistinguisher cookie) {
+ OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>> task =
+ new OFRpcTask<UpdateGroupInput, RpcResult<UpdateGroupOutput>>(taskContext, cookie, input) {
+
+ @Override
+ public ListenableFuture<RpcResult<UpdateGroupOutput>> call() {
+ ListenableFuture<RpcResult<UpdateGroupOutput>> result = null;
+ Collection<RpcError> barrierErrors = OFRpcTaskUtil.manageBarrier(getTaskContext(),
+ getInput().getUpdatedGroup().isBarrier(), getCookie());
+ if (!barrierErrors.isEmpty()) {
+ OFRpcTaskUtil.wrapBarrierErrors(((SettableFuture<RpcResult<UpdateGroupOutput>>) result), barrierErrors);
+ } else {
+ // Convert the UpdateGroupInput to GroupModInput
+ GroupModInputBuilder ofGroupModInput = GroupConvertor.toGroupModInput(
+ getInput().getUpdatedGroup(), getVersion(),
+ getSession().getFeatures().getDatapathId());
+ final Long xId = getSession().getNextXid();
+ ofGroupModInput.setXid(xId);
+
+ Future<RpcResult<UpdateGroupOutput>> resultFromOFLib =
+ getMessageService().groupMod(ofGroupModInput.build(), getCookie());
+ result = JdkFutureAdapters.listenInPoolThread(resultFromOFLib);
+
+ OFRpcTaskUtil.hookFutureNotification(result, getRpcNotificationProviderService(),
+ createGroupUpdatedNotification(xId, getInput()));