X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=applications%2Fforwardingrules-sync%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fapplications%2Ffrsync%2Fimpl%2Fstrategy%2FSyncPlanPushStrategyFlatBatchImpl.java;h=25c833a1757a95242c92da01fb5b355d55c8daa8;hb=59bf5b768c4bcc0a7d25101e8b25d82e5af4be38;hp=8c0661e9d4a4b6bc14b3397e160c5bbc1e1a5ae0;hpb=4c1db5461c2fbd2a72d99b3b21a0050f7c8aec3f;p=openflowplugin.git diff --git a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java index 8c0661e9d4..25c833a175 100644 --- a/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java +++ b/applications/forwardingrules-sync/src/main/java/org/opendaylight/openflowplugin/applications/frsync/impl/strategy/SyncPlanPushStrategyFlatBatchImpl.java @@ -30,45 +30,54 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev16032 import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.ProcessFlatBatchOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.SalFlatBatchService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.FlatBatchAddFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.FlatBatchAddFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.FlatBatchRemoveFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.FlatBatchRemoveFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.FlatBatchUpdateFlowCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.FlatBatchUpdateFlowCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.add.flow._case.FlatBatchAddFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.add.flow._case.FlatBatchAddFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.add.flow._case.FlatBatchAddFlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.remove.flow._case.FlatBatchRemoveFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.remove.flow._case.FlatBatchRemoveFlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.update.flow._case.FlatBatchUpdateFlow; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.flow.crud._case.aug.flat.batch.update.flow._case.FlatBatchUpdateFlowKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.FlatBatchAddGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.FlatBatchAddGroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.FlatBatchRemoveGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.FlatBatchRemoveGroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.FlatBatchUpdateGroupCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.FlatBatchUpdateGroupCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.add.group._case.FlatBatchAddGroup; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.add.group._case.FlatBatchAddGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.add.group._case.FlatBatchAddGroupKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.remove.group._case.FlatBatchRemoveGroup; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.remove.group._case.FlatBatchRemoveGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.remove.group._case.FlatBatchRemoveGroupKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.update.group._case.FlatBatchUpdateGroup; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.update.group._case.FlatBatchUpdateGroupBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.group.crud._case.aug.flat.batch.update.group._case.FlatBatchUpdateGroupKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.FlatBatchAddMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.FlatBatchAddMeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.FlatBatchRemoveMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.FlatBatchRemoveMeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.FlatBatchUpdateMeterCase; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.FlatBatchUpdateMeterCaseBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.add.meter._case.FlatBatchAddMeter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.add.meter._case.FlatBatchAddMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.add.meter._case.FlatBatchAddMeterKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.remove.meter._case.FlatBatchRemoveMeter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.remove.meter._case.FlatBatchRemoveMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.remove.meter._case.FlatBatchRemoveMeterKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.update.meter._case.FlatBatchUpdateMeter; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.update.meter._case.FlatBatchUpdateMeterBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.flat.batch.meter.crud._case.aug.flat.batch.update.meter._case.FlatBatchUpdateMeterKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.Batch; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.BatchBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.BatchChoice; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddFlowCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddGroupCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchAddMeterCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveFlowCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveGroupCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveGroupCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchRemoveMeterCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateFlowCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCase; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateMeterCaseBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.flow._case.FlatBatchAddFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroup; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.group._case.FlatBatchAddGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.add.meter._case.FlatBatchAddMeterBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.flow._case.FlatBatchRemoveFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroup; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.group._case.FlatBatchRemoveGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.remove.meter._case.FlatBatchRemoveMeterBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlow; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.flow._case.FlatBatchUpdateFlowBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroup; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.group._case.FlatBatchUpdateGroupBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeter; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.flat.batch.update.meter._case.FlatBatchUpdateMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.output.BatchFailure; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey; @@ -81,6 +90,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groups.service.rev160315.ba import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.OriginalBatchedMeterBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.meters.service.rev160316.batch.meter.input.update.grouping.UpdatedBatchedMeterBuilder; +import org.opendaylight.yangtools.yang.binding.util.BindingMap; +import org.opendaylight.yangtools.yang.binding.util.BindingMap.Builder; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.Uint16; import org.slf4j.Logger; @@ -137,7 +148,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { .setNode(new NodeRef(PathUtil.digNodePath(diffInput.getNodeIdent()))) // TODO: propagate from input .setExitOnFirstError(false) - .setBatch(batchBag) + .setBatch(BindingMap.ordered(batchBag)) .build(); final ListenableFuture> rpcResultFuture = @@ -161,7 +172,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { @Override public void onSuccess(final RpcResult result) { if (!result.isSuccessful() && result.getResult() != null - && !result.getResult().getBatchFailure().isEmpty()) { + && !result.getResult().nonnullBatchFailure().isEmpty()) { Map, Batch> batchMap = mapBatchesToRanges(inputBatchBag, failureIndexLimit); decrementBatchFailuresCounters(result.getResult().nonnullBatchFailure().values(), batchMap, counters); @@ -228,7 +239,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } @VisibleForTesting - static int assembleRemoveFlows(final List batchBag, int batchOrder, + static int assembleRemoveFlows(final List batchBag, final int batchOrder, final Map> flowItemSyncTableMap) { // process flow remove int order = batchOrder; @@ -237,8 +248,8 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { final ItemSyncBox flowItemSyncBox = syncBoxEntry.getValue(); if (!flowItemSyncBox.getItemsToPush().isEmpty()) { - final List flatBatchRemoveFlowBag = - new ArrayList<>(flowItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchRemoveFlowBag = + BindingMap.orderedBuilder(flowItemSyncBox.getItemsToUpdate().size()); int itemOrder = 0; for (Flow flow : flowItemSyncBox.getItemsToPush()) { flatBatchRemoveFlowBag.add(new FlatBatchRemoveFlowBuilder(flow) @@ -248,7 +259,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchRemoveFlowCaseBuilder() - .setFlatBatchRemoveFlow(flatBatchRemoveFlowBag) + .setFlatBatchRemoveFlow(flatBatchRemoveFlowBag.build()) .build()) .setBatchOrder(Uint16.valueOf(order)) .build(); @@ -261,15 +272,15 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } @VisibleForTesting - static int assembleAddOrUpdateGroups(final List batchBag, int batchOrder, + static int assembleAddOrUpdateGroups(final List batchBag, final int batchOrder, final List> groupsToAddOrUpdate) { // process group add+update int order = batchOrder; if (groupsToAddOrUpdate != null) { for (ItemSyncBox groupItemSyncBox : groupsToAddOrUpdate) { if (!groupItemSyncBox.getItemsToPush().isEmpty()) { - final List flatBatchAddGroupBag = - new ArrayList<>(groupItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchAddGroupBag = + BindingMap.orderedBuilder(groupItemSyncBox.getItemsToPush().size()); int itemOrder = 0; for (Group group : groupItemSyncBox.getItemsToPush()) { flatBatchAddGroupBag.add(new FlatBatchAddGroupBuilder(group) @@ -277,7 +288,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchAddGroupCaseBuilder() - .setFlatBatchAddGroup(flatBatchAddGroupBag) + .setFlatBatchAddGroup(flatBatchAddGroupBag.build()) .build()) .setBatchOrder(Uint16.valueOf(order)) .build(); @@ -286,21 +297,21 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } if (!groupItemSyncBox.getItemsToUpdate().isEmpty()) { - final List flatBatchUpdateGroupBag = - new ArrayList<>(groupItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchUpdateGroupBag = + BindingMap.orderedBuilder(groupItemSyncBox.getItemsToUpdate().size()); int itemOrder = 0; for (ItemSyncBox.ItemUpdateTuple groupUpdate : groupItemSyncBox.getItemsToUpdate()) { flatBatchUpdateGroupBag.add(new FlatBatchUpdateGroupBuilder() - .setBatchOrder(itemOrder++) + .setBatchOrder(Uint16.valueOf(itemOrder++)) .setOriginalBatchedGroup(new OriginalBatchedGroupBuilder(groupUpdate.getOriginal()).build()) .setUpdatedBatchedGroup(new UpdatedBatchedGroupBuilder(groupUpdate.getUpdated()).build()) .build()); } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchUpdateGroupCaseBuilder() - .setFlatBatchUpdateGroup(flatBatchUpdateGroupBag) + .setFlatBatchUpdateGroup(flatBatchUpdateGroupBag.build()) .build()) - .setBatchOrder(order) + .setBatchOrder(Uint16.valueOf(order)) .build(); order += itemOrder; batchBag.add(batch); @@ -311,25 +322,25 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } @VisibleForTesting - static int assembleRemoveGroups(final List batchBag, int batchOrder, + static int assembleRemoveGroups(final List batchBag, final int batchOrder, final List> groupsToRemoveOrUpdate) { // process group add+update int order = batchOrder; if (groupsToRemoveOrUpdate != null) { for (ItemSyncBox groupItemSyncBox : groupsToRemoveOrUpdate) { if (!groupItemSyncBox.getItemsToPush().isEmpty()) { - final List flatBatchRemoveGroupBag = - new ArrayList<>(groupItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchRemoveGroupBag = + BindingMap.orderedBuilder(groupItemSyncBox.getItemsToUpdate().size()); int itemOrder = 0; for (Group group : groupItemSyncBox.getItemsToPush()) { flatBatchRemoveGroupBag.add(new FlatBatchRemoveGroupBuilder(group) - .setBatchOrder(itemOrder++).build()); + .setBatchOrder(Uint16.valueOf(itemOrder++)).build()); } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchRemoveGroupCaseBuilder() - .setFlatBatchRemoveGroup(flatBatchRemoveGroupBag) + .setFlatBatchRemoveGroup(flatBatchRemoveGroupBag.build()) .build()) - .setBatchOrder(order) + .setBatchOrder(Uint16.valueOf(order)) .build(); order += itemOrder; batchBag.add(batch); @@ -340,44 +351,46 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } @VisibleForTesting - static int assembleAddOrUpdateMeters(final List batchBag, int batchOrder, + static int assembleAddOrUpdateMeters(final List batchBag, final int batchOrder, final ItemSyncBox meterItemSyncBox) { // process meter add+update int order = batchOrder; if (meterItemSyncBox != null) { if (!meterItemSyncBox.getItemsToPush().isEmpty()) { - final List flatBatchAddMeterBag = - new ArrayList<>(meterItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchAddMeterBag = + BindingMap.orderedBuilder(meterItemSyncBox.getItemsToPush().size()); int itemOrder = 0; for (Meter meter : meterItemSyncBox.getItemsToPush()) { - flatBatchAddMeterBag.add(new FlatBatchAddMeterBuilder(meter).setBatchOrder(itemOrder++).build()); + flatBatchAddMeterBag.add(new FlatBatchAddMeterBuilder(meter) + .setBatchOrder(Uint16.valueOf(itemOrder++)) + .build()); } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchAddMeterCaseBuilder() - .setFlatBatchAddMeter(flatBatchAddMeterBag) + .setFlatBatchAddMeter(flatBatchAddMeterBag.build()) .build()) - .setBatchOrder(order) + .setBatchOrder(Uint16.valueOf(order)) .build(); order += itemOrder; batchBag.add(batch); } if (!meterItemSyncBox.getItemsToUpdate().isEmpty()) { - final List flatBatchUpdateMeterBag = - new ArrayList<>(meterItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchUpdateMeterBag = + BindingMap.orderedBuilder(meterItemSyncBox.getItemsToUpdate().size()); int itemOrder = 0; for (ItemSyncBox.ItemUpdateTuple meterUpdate : meterItemSyncBox.getItemsToUpdate()) { flatBatchUpdateMeterBag.add(new FlatBatchUpdateMeterBuilder() - .setBatchOrder(itemOrder++) + .setBatchOrder(Uint16.valueOf(itemOrder++)) .setOriginalBatchedMeter(new OriginalBatchedMeterBuilder(meterUpdate.getOriginal()).build()) .setUpdatedBatchedMeter(new UpdatedBatchedMeterBuilder(meterUpdate.getUpdated()).build()) .build()); } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchUpdateMeterCaseBuilder() - .setFlatBatchUpdateMeter(flatBatchUpdateMeterBag) + .setFlatBatchUpdateMeter(flatBatchUpdateMeterBag.build()) .build()) - .setBatchOrder(order) + .setBatchOrder(Uint16.valueOf(order)) .build(); order += itemOrder; batchBag.add(batch); @@ -387,22 +400,24 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } @VisibleForTesting - static int assembleRemoveMeters(final List batchBag, int batchOrder, + static int assembleRemoveMeters(final List batchBag, final int batchOrder, final ItemSyncBox meterItemSyncBox) { // process meter remove int order = batchOrder; if (meterItemSyncBox != null && !meterItemSyncBox.getItemsToPush().isEmpty()) { - final List flatBatchRemoveMeterBag = - new ArrayList<>(meterItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchRemoveMeterBag = + BindingMap.orderedBuilder(meterItemSyncBox.getItemsToPush().size()); int itemOrder = 0; for (Meter meter : meterItemSyncBox.getItemsToPush()) { - flatBatchRemoveMeterBag.add(new FlatBatchRemoveMeterBuilder(meter).setBatchOrder(itemOrder++).build()); + flatBatchRemoveMeterBag.add(new FlatBatchRemoveMeterBuilder(meter) + .setBatchOrder(Uint16.valueOf(itemOrder++)) + .build()); } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchRemoveMeterCaseBuilder() - .setFlatBatchRemoveMeter(flatBatchRemoveMeterBag) + .setFlatBatchRemoveMeter(flatBatchRemoveMeterBag.build()) .build()) - .setBatchOrder(order) + .setBatchOrder(Uint16.valueOf(order)) .build(); order += itemOrder; batchBag.add(batch); @@ -411,7 +426,7 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } @VisibleForTesting - static int assembleAddOrUpdateFlows(final List batchBag, int batchOrder, + static int assembleAddOrUpdateFlows(final List batchBag, final int batchOrder, final Map> flowItemSyncTableMap) { // process flow add+update int order = batchOrder; @@ -420,32 +435,32 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { final ItemSyncBox flowItemSyncBox = syncBoxEntry.getValue(); if (!flowItemSyncBox.getItemsToPush().isEmpty()) { - final List flatBatchAddFlowBag = - new ArrayList<>(flowItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchAddFlowBag = + BindingMap.orderedBuilder(flowItemSyncBox.getItemsToPush().size()); int itemOrder = 0; for (Flow flow : flowItemSyncBox.getItemsToPush()) { flatBatchAddFlowBag.add(new FlatBatchAddFlowBuilder(flow) - .setBatchOrder(itemOrder++) + .setBatchOrder(Uint16.valueOf(itemOrder++)) .setFlowId(flow.getId()) .build()); } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchAddFlowCaseBuilder() - .setFlatBatchAddFlow(flatBatchAddFlowBag) + .setFlatBatchAddFlow(flatBatchAddFlowBag.build()) .build()) - .setBatchOrder(order) + .setBatchOrder(Uint16.valueOf(order)) .build(); order += itemOrder; batchBag.add(batch); } if (!flowItemSyncBox.getItemsToUpdate().isEmpty()) { - final List flatBatchUpdateFlowBag = - new ArrayList<>(flowItemSyncBox.getItemsToUpdate().size()); + final Builder flatBatchUpdateFlowBag = + BindingMap.orderedBuilder(flowItemSyncBox.getItemsToUpdate().size()); int itemOrder = 0; for (ItemSyncBox.ItemUpdateTuple flowUpdate : flowItemSyncBox.getItemsToUpdate()) { flatBatchUpdateFlowBag.add(new FlatBatchUpdateFlowBuilder() - .setBatchOrder(itemOrder++) + .setBatchOrder(Uint16.valueOf(itemOrder++)) .setFlowId(flowUpdate.getUpdated().getId()) .setOriginalBatchedFlow(new OriginalBatchedFlowBuilder(flowUpdate.getOriginal()).build()) .setUpdatedBatchedFlow(new UpdatedBatchedFlowBuilder(flowUpdate.getUpdated()).build()) @@ -453,9 +468,9 @@ public class SyncPlanPushStrategyFlatBatchImpl implements SyncPlanPushStrategy { } final Batch batch = new BatchBuilder() .setBatchChoice(new FlatBatchUpdateFlowCaseBuilder() - .setFlatBatchUpdateFlow(flatBatchUpdateFlowBag) + .setFlatBatchUpdateFlow(flatBatchUpdateFlowBag.build()) .build()) - .setBatchOrder(order) + .setBatchOrder(Uint16.valueOf(order)) .build(); order += itemOrder; batchBag.add(batch);