2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.applications.frsync.impl.strategy;
11 import org.opendaylight.openflowplugin.applications.frsync.util.ItemSyncBox;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.Meter;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.meters.MeterBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId;
23 * Provides create methods for data involved in {@link SynchronizationDiffInput}.
25 public class DiffInputFactory {
26 static ItemSyncBox<Group> createGroupSyncBox(final long... groupIDs) {
27 final ItemSyncBox<Group> groupBox = new ItemSyncBox<>();
29 for (long gid : groupIDs) {
30 groupBox.getItemsToPush().add(createPlainGroup(gid));
35 static ItemSyncBox<Group> createGroupSyncBoxWithUpdates(final long... groupIDs) {
36 final ItemSyncBox<Group> groupBox = new ItemSyncBox<>();
38 for (long gid : groupIDs) {
39 groupBox.getItemsToPush().add(createPlainGroup(gid));
40 groupBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(createPlainGroup(gid + 50),
41 createPlainGroup(gid + 100)));
46 private static Group createPlainGroup(final long gid) {
47 return new GroupBuilder().setGroupId(new GroupId(gid)).build();
50 static ItemSyncBox<Meter> createMeterSyncBox(final long... meterIDs) {
51 final ItemSyncBox<Meter> groupBox = new ItemSyncBox<>();
53 for (long gid : meterIDs) {
54 groupBox.getItemsToPush().add(createPlainMeter(gid));
59 static ItemSyncBox<Meter> createMeterSyncBoxWithUpdates(final long... meterIDs) {
60 final ItemSyncBox<Meter> groupBox = new ItemSyncBox<>();
62 for (long mid : meterIDs) {
63 groupBox.getItemsToPush().add(createPlainMeter(mid));
64 groupBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(createPlainMeter(mid + 50),
65 createPlainMeter(mid + 100)));
70 private static Meter createPlainMeter(final long mid) {
71 return new MeterBuilder().setMeterId(new MeterId(mid)).build();
74 static ItemSyncBox<Flow> createFlowSyncBox(final String... flowIDs) {
75 final ItemSyncBox<Flow> flowBox = new ItemSyncBox<>();
77 for (String fid : flowIDs) {
78 flowBox.getItemsToPush().add(createPlainFlow(fid));
83 static ItemSyncBox<Flow> createFlowSyncBoxWithUpdates(final String... flowIDs) {
84 final ItemSyncBox<Flow> groupBox = new ItemSyncBox<>();
86 for (String fid : flowIDs) {
87 groupBox.getItemsToPush().add(createPlainFlow(fid));
88 groupBox.getItemsToUpdate().add(new ItemSyncBox.ItemUpdateTuple<>(createPlainFlow(fid + "orig"),
89 createPlainFlow(fid + "upd")));
94 private static Flow createPlainFlow(final String fid) {
95 return new FlowBuilder().setId(new FlowId(fid)).build();