use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyFlatBatchImpl method assembleAddOrUpdateGroups.
@VisibleForTesting
static int assembleAddOrUpdateGroups(final List<Batch> batchBag, int batchOrder, final List<ItemSyncBox<Group>> groupsToAddOrUpdate) {
// process group add+update
int order = batchOrder;
if (groupsToAddOrUpdate != null) {
for (ItemSyncBox<Group> groupItemSyncBox : groupsToAddOrUpdate) {
if (!groupItemSyncBox.getItemsToPush().isEmpty()) {
final List<FlatBatchAddGroup> flatBatchAddGroupBag = new ArrayList<>(groupItemSyncBox.getItemsToUpdate().size());
int itemOrder = 0;
for (Group group : groupItemSyncBox.getItemsToPush()) {
flatBatchAddGroupBag.add(new FlatBatchAddGroupBuilder(group).setBatchOrder(itemOrder++).build());
}
final Batch batch = new BatchBuilder().setBatchChoice(new FlatBatchAddGroupCaseBuilder().setFlatBatchAddGroup(flatBatchAddGroupBag).build()).setBatchOrder(order).build();
order += itemOrder;
batchBag.add(batch);
}
if (!groupItemSyncBox.getItemsToUpdate().isEmpty()) {
final List<FlatBatchUpdateGroup> flatBatchUpdateGroupBag = new ArrayList<>(groupItemSyncBox.getItemsToUpdate().size());
int itemOrder = 0;
for (ItemSyncBox.ItemUpdateTuple<Group> groupUpdate : groupItemSyncBox.getItemsToUpdate()) {
flatBatchUpdateGroupBag.add(new FlatBatchUpdateGroupBuilder().setBatchOrder(itemOrder++).setOriginalBatchedGroup(new OriginalBatchedGroupBuilder(groupUpdate.getOriginal()).build()).setUpdatedBatchedGroup(new UpdatedBatchedGroupBuilder(groupUpdate.getUpdated()).build()).build());
}
final Batch batch = new BatchBuilder().setBatchChoice(new FlatBatchUpdateGroupCaseBuilder().setFlatBatchUpdateGroup(flatBatchUpdateGroupBag).build()).setBatchOrder(order).build();
order += itemOrder;
batchBag.add(batch);
}
}
}
return order;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flat.batch.service.rev160321.process.flat.batch.input.batch.batch.choice.FlatBatchUpdateGroupCaseBuilder in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyFlatBatchImplTest method testDecrementCounters.
@Test
public void testDecrementCounters() throws Exception {
final SyncCrudCounters counters = new SyncCrudCounters();
counters.getFlowCrudCounts().setAdded(100);
counters.getFlowCrudCounts().setUpdated(100);
counters.getFlowCrudCounts().setRemoved(100);
counters.getGroupCrudCounts().setAdded(100);
counters.getGroupCrudCounts().setUpdated(100);
counters.getGroupCrudCounts().setRemoved(100);
counters.getMeterCrudCounts().setAdded(100);
counters.getMeterCrudCounts().setUpdated(100);
counters.getMeterCrudCounts().setRemoved(100);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchAddFlowCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchUpdateFlowCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchRemoveFlowCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchAddGroupCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchUpdateGroupCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchRemoveGroupCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchAddMeterCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchUpdateMeterCaseBuilder().build(), counters);
SyncPlanPushStrategyFlatBatchImpl.decrementCounters(new FlatBatchRemoveMeterCaseBuilder().build(), counters);
Assert.assertEquals(99, counters.getFlowCrudCounts().getAdded());
Assert.assertEquals(99, counters.getFlowCrudCounts().getUpdated());
Assert.assertEquals(99, counters.getFlowCrudCounts().getRemoved());
Assert.assertEquals(99, counters.getGroupCrudCounts().getAdded());
Assert.assertEquals(99, counters.getGroupCrudCounts().getUpdated());
Assert.assertEquals(99, counters.getGroupCrudCounts().getRemoved());
Assert.assertEquals(99, counters.getMeterCrudCounts().getAdded());
Assert.assertEquals(99, counters.getMeterCrudCounts().getUpdated());
Assert.assertEquals(99, counters.getMeterCrudCounts().getRemoved());
}
Aggregations